Vertical viewport was given unbounded height for SizedBox inside container

I'm trying to insert a ListView to take the remaining space of a Column. Using Expanded(child: ListView) does not work, I have to use a SizedBox with a height:

Widget build(BuildContext context) {
    return Column(children: [
      ExpandableListTitle(title: widget.title),
      Container(
          margin: const EdgeInsets.only(left: 5, top: 10, right: 5),
          child: SizedBox(
              height: 280, // <<<<<< If I take this out, I get error
              child: ListView(
                scrollDirection: Axis.vertical,
                children: widget.children,
              )))
    ]);
  }

Where ExpandableListTitle is just a container:

ExpandableListTitle({Key key, this.title}) : super(key: key);
  final String title;

  @override
  Widget build(BuildContext context) {
    return Container(
        margin: const EdgeInsets.only(bottom: 0),
        child: Column(

If I don't give a height to the SizedBox as you see above, I get

Vertical viewport was given unbounded height.

I want this column to fill the remaining space. I tried changing from SizedBox to Expanded but I still get the same problem.



Read more here: https://stackoverflow.com/questions/64949893/vertical-viewport-was-given-unbounded-height-for-sizedbox-inside-container

Content Attribution

This content was originally published by Paprika at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: