小编fha*_*s21的帖子

Flutter 水平 ListView BoxConstraints 强制无限宽度

目前我尝试在卡片中显示水平 ListView Builder。但我总是收到一条错误消息“ BoxConstraints 强制无限宽度”。

如果我构建一个带有垂直列表的列表视图,一切都会正常。一旦我更改为水平列表,该列表就会消失。

我将附上一个屏幕截图,其中标记了水平列表视图应位于的区域。 当前视图的截图

这是我对第二张卡的最后一次尝试:(我删除了第一张卡的代码,因此代码不会太长)

Expanded(
child: Container(
height: 250.0,
child: Card(
color: Color(_colors.getBackgroundColor()),
elevation: 10.0,
shadowColor: Colors.black54,
margin: EdgeInsets.all(8.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
side: BorderSide(
color: Color(_colors.getLightMainColor()))),
     child: Padding(
         padding: const EdgeInsets.all(8.0),
            child: Container(
              width: 250.0,
               child: ListView.builder(
               scrollDirection: Axis.horizontal,
               itemCount: 1,
               itemBuilder: (context, index) {
               return ListTile(
               title: Text('Test'),
                  );
                 }),
               )),
              ),
             ),
   ),
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-layout

1
推荐指数
1
解决办法
1612
查看次数

标签 统计

dart ×1

flutter ×1

flutter-layout ×1