close

[Solved] Flutter: RenderBox was not laid out

Hello Guys how are you all ? Hope you all are fine. By using Flutter might be all flutter developer faced this error RenderBox was not laid out in Flutter.

I am trying to make ListView in my project file. Everything was working Fine. But when I applied Text Widget in my ListView builder. There is Some issue to use Text Widget.

What is Error

In my case, while I am using ListView inside a Column/Row. The text in the exception gives an error RenderBox was not laid out. As shown below.

Here Is My Code Where I am faced this Error

Error That I got In stack track

Solutions

Column tries to expands in vertical axis, and so does the ListView, hence you need to constrain the height of ListView.

Error is thrown cause of Column is try to expands in vertical axis, that’s why you need to constrain the height of ListView.

Question: How to Solve Another exeption was thrown: RanderBox was not laid out ?
Answer: Error is thrown cause of Column is try to expands in vertical axis, that’s why you need to constrain the height of ListView.

Solution 1 : Use Expanded Widget

Use Expanded if you want to allow ListView to take up entire left space in Column.

Solution 2 : Use Flexible Widget

Use Flexible if you want to allow ListView to take up entire left space in Column.

Solution 3 : Use SizedBox.

We Might Use SizeBox. if you want to restrict the size of ListView to a certain height.

Solution 4 : Use shrinkWrap Property of ListView

Use shrinkWrap, if your ListView isn’t too big.

Solution 5 : Wrap your ListView in an Expanded widget

Wrap your ListView in an Expanded widget

So Hope This Above 5 Solution Will Work For You Too. So it’s all About Flutter: RenderBox was not laid out error. Hope this tutorial helped you a lot. Comment below Your thoughts and your queries. And Also Comment on your suggestion here.

Also Read

1 thought on “[Solved] Flutter: RenderBox was not laid out”

Leave a Comment

%d bloggers like this: