【问题标题】:i have problem in flutter code. Its giving be RenderCustomMultiChildLayoutBox object was given an infinite size during layout我在颤振代码中有问题。它的给定是 RenderCustomMultiChildLayoutBox 对象在布局期间被赋予无限大小
【发布时间】:2021-06-25 02:15:21
【问题描述】:

我是 Flutter 的新手,正在尝试在 Flutter 中实现自定义列表视图。在布局错误期间,它的给定 RenderCustomMultiChildLayoutBox 对象被赋予无限大小

我无法获取哪个小部件的抛出错误 2 另外请建议如何调试这些布局错误,因为错误跟踪没有引发错误的特定小部件信息

请在下面找到相同的代码:

_list.length <= 0
        ? Center(
            child: Text('Add from bottom button',
                style: TextStyle(
                    fontSize: 20,
                    fontWeight: FontWeight.bold,
                    fontStyle: FontStyle.italic,
                    color: Colors.blue)))
        : Column(
            children: [Container(
              height: 200,
              child: ListView.builder(
                itemBuilder: (context, index) => _list[index],
                itemCount: _list.length,
              ),
            ),
         ] ),

【问题讨论】:

    标签: android flutter dart flutter-layout


    【解决方案1】:

    您将列表视图包装在 ColumnContainer 小部件中。列有无限的宽度和高度。您应该向容器提供 width 并在 ListView 中启用 shrinkWrap 为 true。找到下面的代码sn-ps:

    _list.length <= 0
            ? Center(
                child: Text('Add from bottom button',
                    style: TextStyle(
                        fontSize: 20,
                        fontWeight: FontWeight.bold,
                        fontStyle: FontStyle.italic,
                        color: Colors.blue)))
            : Column(
                children: [Container(
                  width: 360, 
                  height: 200,
                  child: ListView.builder(
                    shrinkWrap: true,
                    itemBuilder: (context, index) => _list[index],
                    itemCount: _list.length,
                  ),
                ),
             ] ),
    

    【讨论】:

      猜你喜欢
      • 2019-05-13
      • 2020-05-20
      • 1970-01-01
      • 2020-04-15
      • 2020-08-13
      • 2021-08-06
      • 2021-09-06
      • 2018-03-31
      • 2021-05-13
      相关资源
      最近更新 更多