当Column嵌套ListView的时候报错Vertical viewport was given unbounded height
报错
I/flutter ( 5087): Another exception was thrown: Vertical viewport was given unbounded height.
I/flutter ( 5087): Another exception was thrown: RenderBox was not laid out: RenderViewport#44459 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 5087): Another exception was thrown: RenderBox was not laid out: RenderViewport#44459 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 5087): Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#211c7 relayoutBoundary=up11 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 5087): Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#4326e relayoutBoundary=up10 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 5087): Another exception was thrown: RenderBox was not laid out: RenderPointerListener#fc43d relayoutBoundary=up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 5087): Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#4e169 relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 5087): Another exception was thrown: RenderBox was not laid out: RenderPointerListener#a9420 relayoutBoundary=up7 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 5087): Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#a16d1 relayoutBoundary=up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 5087): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#7a143 relayoutBoundary=up5 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 5087): Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#f7141 relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 5087): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#eb9a9 relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 5087): Another exception was thrown: RenderBox was not laid out: RenderFlex#6c383 relayoutBoundary=up2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 5087): Another exception was thrown: RenderBox was not laid out: RenderPadding#aaf78 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 5087): Another exception was thrown: Null check operator used on a null value
原因:ListView不知道高度是多少,就报错了
解决:在ListView外面嵌套一个Expanded或Container
@override
Widget build(BuildContext context) {
return getBaseThemeBar(
'测试listview',
Padding(
padding: EdgeInsets.all(10.0),
child: Column(
children: [
Expanded(
child: ListView.builder(
itemBuilder: _getListData, itemCount: this._items.length))
],
),
));
}
网友评论