Flutter ListView Error: RenderBox was not laid out: RenderViewport#680c1 NEEDS-LAYOUT NEEDS-PAINT

RenderBox was not laid out: RenderViewport#680c1 NEEDS-LAYOUT NEEDS-PAINT

When using listview.builder() layout, this error may be reported if it is nested in row or column. The reason is that the size is not specified for the listview, so a sizedbox or container should be set outside the listview, and then a height should be specified. Or if you want to adapt the height, set a flexible or expanded.

return Scaffold(
      body: SafeArea(
        left: false,
        right: false,
        child: Container(
          padding: EdgeInsets.fromLTRB(0, 12, 0, 36),
          child: Column(children: [
	  ......
	  other components
	  ......
	    Expanded(
                child: Container(
              child: ListView(
                  children: []
                    ..add(row('Anywhere'))
                    ..add(or())
                    ..add(row('Country'))
                    ..add(row('State'))),
            )),
	  ......
	  other components
	  ......
	  ]))));

If the screen is still blank, try setting shrinkwrap to true and physics to neverscrollablescrollphysics()

Similar Posts: