【问题标题】:Flutter - Container height same as child heightFlutter - 容器高度与子高度相同
【发布时间】:2021-09-02 05:27:20
【问题描述】:

我在 Column -> Container 下有一个子 Axis.horizo​​ntal ListView.builder。我想要容器中的自动高度

Column(
            children: [
              Padding(...),
              Container(
                height: 200,
                child: ListView.builder(
                  shrinkWrap: true,
                  itemCount: 6,
                  scrollDirection: Axis.horizontal,
                  itemBuilder: (context, index) {
                    return brandListLayout('brandList![index]');
                  },
                ),
              ),
            ],
          ),

【问题讨论】:

  • 将您的容器包装在展开的小部件中
  • @Brightcode 是水平的 ListView,所以我不想让我的 listview 包裹我的整个屏幕
  • 您可能必须在容器中使用约束框,并为容器设置最小和最大高度
  • 我现在不知道列表视图项的最小/最大高度是多少。它会因不同的设备而自动不同

标签: flutter dart flutter-layout


【解决方案1】:

如果你想通过不同的设备调整 ListView 的高度,
我建议使用“ScreenUtil”或“Sizer”包。

【讨论】:

    猜你喜欢
    • 2018-12-07
    • 2020-07-07
    • 2022-11-04
    • 2020-06-20
    • 1970-01-01
    • 1970-01-01
    • 2021-11-11
    • 2022-12-18
    相关资源
    最近更新 更多