close

flutter: renderbox was not laid out

When stacking shows it in a listView in some cases it might toss a mistake. How to Solve Render Box Was not Laid Out In Flutter?

How to Solve Render Box Was not Laid Out In Flutter?

This is somewhat blunder for the most part happens when the client puts a ListView Widget inside Row Widget or Column Widget. To maintain a strategic distance from this mistake clients need to give a size to the ListView inside.

Here section attempts to extend in the vertical hub, thus does the ListView, henceforth you need to compel the tallness of ListView.

Solutions: 

  • Utilize either Expanded or Flexible on the off chance that you need to permit ListView to occupy the whole left room in Column.
Column(
  children: <Widget>[
    Expanded(
      child: ListView(...),
    )
  ],
)
  • Use SizedBox on the off chance that you need to limit the size of ListView to a specific stature.
Column(
  children: <Widget>[
    SizedBox(
      height: 200, // constrain height
      child: ListView(),
    )
  ],
)
  • Use shrinkWrap, if your ListView isn’t too enormous.
Column(
  children: <Widget>[
    ListView(
      shrinkWrap: true, // use it
    )
  ],
)
  • Setting your rundown see in a Flexible Widget may likewise help,
Flexible( fit: FlexFit.tight, child: _buildYourListWidget(..),)
  • Wrap your ListView in an Expanded gadget
Expanded(child:MyListView())
  • Consider a code which utilizes an Expanded to advise the level size and the SizedBox for the tallness:
new Row(
   children: <Widget>[
     Expanded(
       child: SizedBox(
         height: 200.0,
         child: new ListView.builder(
           scrollDirection: Axis.horizontal,
           itemCount: products.length,
           itemBuilder: (BuildContext ctxt, int index) {
             return new Text(products[index]);
           },
         ),
       ),
     ),
     new IconButton(
       icon: Icon(Icons.remove_circle),
       onPressed: () {},
     ),
   ],
   mainAxisAlignment: MainAxisAlignment.spaceBetween,
 )

Conclusion:

In this article, We have experienced How to Solve Render Box Was not Laid Out In Flutter?

A debt of gratitude is in order for Reading !!! Continue Learning !!!

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment