当我将ListView放在列中时,出现了“引发了另一个异常:RenderBox未被布置”

时间:2019-04-18 00:46:43

标签: android dart flutter

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

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

1 个答案:

答案 0 :(得分:0)

您可以使用shrinkWrap的{​​{1}}属性。

ListView

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

不要忘记在ListView.builder( shrinkWrap: true, ... 内返回一个Widget

itemBuilder