flutter - 如何在flutter中并排对齐 ListView 中的项目?

标签 flutter dart

我的要求是在列表 View 中安排以下项目:

item 1  item2
item 3  item4
item 5  item6
我目前正在使用ListView及其子级作为Wrap小部件(以在下一行中安排项目)
我的输出是这样的
item 1 item 4
item 2 item 5
item 3 item 6
如何在 flutter 打中达到我的要求

最佳答案

最好的方法是使用GridView。这确实意味着您需要的那种布局。
这是有关如何使用GridViewexample:

GridView.count(
  // Create a grid with 2 columns. If you change the scrollDirection to
  // horizontal, this produces 2 rows.
  crossAxisCount: 2,
  // Generate 100 widgets that display their index in the List.
  children: List.generate(100, (index) {
    return Center(
      child: Text(
        'Item $index',
        style: Theme.of(context).textTheme.headline5,
      ),
    );
  }),
);
这是一张显示GridViewListView之间的布局差异的图片:
enter image description here

关于flutter - 如何在flutter中并排对齐 ListView 中的项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63468731/

相关文章:

android - Flutter Assets 包位于何处?

dart - 如果 set 文字是 set 类型,那么它在 dart 中的类是什么?

installation - 如何安装 Dart 包的更新版本?

regex - Safari 对前瞻和后置 RegExp 的支持

android - Flutter 如何使用 AssetBundle 存储和访问文件

dart - 有什么办法可以将数据从服务器发送到dart的客户端

button - flutter中如何识别点击了哪个按钮

flutter - 如何为 flutter web 更新 pub 包 webdev

android - 尝试运行时在我的第一个Flutter应用中出现错误

Flutter Facebook 登录允许切换帐户