1

I have a column that has 3 children. The third child has a ListView. How do I set the height of the ListView such that it does not overflow the screen. I do not want to calculate the height by subtracting the height of other 2 children from the screen height. I tried LayoutBuilder but the box constraint I get has Infinity as max height (BoxConstraints(0.0<=w<=360.0, 0.0<=h<=Infinity) )

My widget tree looks something like this

Container( //Container A
 height: MediaQuery.of(context).size.height,
 child:Column(children:[
 TitleWidget(),
 SubtitleWidget(),
 Container( //Container B
 child:ListView(children:getChildren())
 ) 
 ])
)

The height of the Container A is the screen height. But height of Container B should be Screen height - height of TitleWidget() - height of SubtitleWidget(). If i don't set the height of container B explicitly, I am getting "A RenderFlex overflowed by X pixels on the bottom".

Am I missing something really obvious here?

thanks

asked Oct 21, 2018 at 19:06

2 Answers 2

2

Wrap you list view with Expanded widget instead of Container widget.

answered Oct 21, 2018 at 19:09
Sign up to request clarification or add additional context in comments.

Comments

1

I had a Similar Issue. In my case, I kept the Container and in my ListView I added shrinkWrap: true, this will shrink the size of the ListView to the total height of all it's children.

And physics: NeverScrollableScrollPhysics(), I Specifically don't want the ListView to scroll under the column items, but I want everything to scroll together.

answered Oct 22, 2018 at 3:12

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.