gpt4 book ai didi

android - 当我将ListView放在列中时得到 “Another exception was thrown: RenderBox was not laid out”

转载 作者:行者123 更新时间:2023-12-03 02:56:34 26 4
gpt4 key购买 nike

我最近在Column和SingleChildScrollView内部制作了一个ListView
但是它显示出诸如“NEEDS PAINT”之类的错误。.这是我的 body 代码

body: Container(
child: SingleChildScrollView(
child: Column(
children: <Widget>[
ListView.builder(
itemCount: 4,
itemBuilder: (BuildContext context, int index) {
Text("Hoi");
},
)
],
),
),
),

我想归还“Hoi” 4次..但是它向我显示了类似的内容
Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#6c04f relayoutBoundary=up1 NEEDS-PAINT

最佳答案

您可以使用shrinkWrapListView属性。

ListView.builder(
shrinkWrap: true,
...

更多信息: https://docs.flutter.io/flutter/widgets/ScrollView/shrinkWrap.html

并且不要忘记在 Widget中返回一个 itemBuilder
       itemBuilder: (BuildContext context, int index) {
return Text("Hoi");
},

关于android - 当我将ListView放在列中时得到 “Another exception was thrown: RenderBox was not laid out”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55737730/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com