【问题标题】:an empty widget is created when trying to iterate through a list and create widget in flutter尝试遍历列表并在颤动中创建小部件时会创建一个空小部件
【发布时间】:2019-05-09 21:03:48
【问题描述】:

我正在尝试遍历列表并在颤动中呈现多个小部件。我的清单有两个项目。奇怪的是,这两个项目都被构建了,但它们之间的空白空间也被构建了。 这是我的代码:

 Column(
            children: state.homePageData.categories
                .map((item) => Container(
                    height: 100,
                    width: double.infinity,
                    child: Column(
                      children: <Widget>[
                        Image.network(
                          baseUrl + item.img.toString(),
                          height: 100,
                          width: 100,
                        ),
                      ],
                    )))
                .toList(),
          )

【问题讨论】:

    标签: dart flutter


    【解决方案1】:

    这不是一个空的小部件,但图像本身并没有填满容器的高度。尝试将 fit 属性添加到图像小部件。您可以在 FitBox 枚举 here

    上找到更多信息

    【讨论】:

      猜你喜欢
      • 2020-12-10
      • 2022-11-12
      • 1970-01-01
      • 1970-01-01
      • 2020-07-13
      • 2022-01-25
      • 2021-03-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多