dart - 我如何在容器内构建 ListView 滚动?

标签 dart flutter flutter-layout

如何使 ListView 像图像一样水平滚动

另一种解释我想在黑色容器内建立这样一个滚动列表 截图

![在此处输入图片描述][1]

代码

    body: Center (
       child: Container(
        height: 400.0,
        width: 300.0,        
        color: Colors.white,
        child: Container(
          margin: EdgeInsets.symmetric(vertical: 90.0),
          child: ListView(
            // This next line does the trick.
            scrollDirection: Axis.horizontal,
            children: <Widget>[
              Container(
                width: 160.0,
                color: Colors.red,
              ),
              Container(
                width: 160.0,
                color: Colors.blue,
              ),
              Container(
                width: 160.0,
                color: Colors.green,
              ),
              Container(
                width: 160.0,
                color: Colors.yellow,
              ),
              Container(
                width: 160.0,
                color: Colors.orange,
              ),
            ],
          )
        ),    
      ),
    )

最佳答案

您知道列小部件吗?如果不是,请尝试并告诉我这是否是您想要的

关于dart - 我如何在容器内构建 ListView 滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55460110/

相关文章:

flutter - 如何将 Future<bool> 转换为 Stream<bool>

xcode - 非公开 API 使用 Flutter.framework/Flutter : _kCTFontOpticalSizeAttribute error on upload of flutter app

android - Flutter Jitsi 在 Release模式下停止

flutter - AppBar 中的扩展小部件

dart - 在JavaScript中,如何使用Dart生成的JavaScript文件?

firebase - 为什么 Firebase 动态链接总是空的?

debugging - flutter : A procedure runs well in debug mode but not after release, 为什么?

flutter - 如何禁用 ElevatedButton?

flutter - Flutter 小部件内的条件填充

flutter - MediaQuery 与 IntrinsicHeight