RenderBox was not laid out: RenderFlex.....
这是因为ListView或Column或Row嵌套ListView,会有问题,解决办法如下:
一、ListView嵌套ListView问题:
ListView( children: <Widget>[ ListView( shrinkWrap: true, //为true可以解决子控件必须设置高度的问题 physics:NeverScrollableScrollPhysics(),//禁用滑动事件 ), ], )如果需要两个listview同时滑动,则需要向他们传同一个scrollcontroller
ScrollController _scrollController; ListView( controller:_scrollController, children: <Widget>[ ListView( controller:_scrollController, ), ], )二、Column嵌套ListView问题,给listView套个有高度的Container或SizedBox:
Column( children: <Widget>[ Container( height: ScreenUtil().setHeight(800), child: ListView.builder( scrollDirection: Axis.vertical, itemBuilder:(context,index){ return _getListItem(index); }, itemCount: list.length, ), ), ], )上面的问题也能用expanede解决,更加灵活,见:Flutter Column等容器嵌套ListView报错
以上两个问题,都是因为嵌套着和被嵌套着都存在滚动问题,滚动冲突了。