android - Flutter - 删除 ListView 中项目之间的空间

标签 android ios flutter padding

我正在使用 ListView.builder 函数来创建项目列表。然而,iOS 中每个项目之间的空间很大(截图)。你知道如何删除项目吗?好像是默认的,因为我没有加。

代码:

ListView :

return Scaffold(
    body: ListView.builder(
          itemCount: data.length,
          itemBuilder: (context, index) {
            final model = data[index];
            if (model.path.isEmpty)
              return Divider(color: Colors.grey[500], indent: 40.0);
            else
              return ItemMenu(model.path, model.name);
          }),

);

项目:

return Row(
  crossAxisAlignment: CrossAxisAlignment.center,
  mainAxisAlignment: MainAxisAlignment.start,
  children: <Widget>[
    Image.asset(path, width: 100, height: 100,color: Colors.grey[500]),
    Text(name, style: MyTextTheme().getLightSmallGrey().copyWith(fontSize: 20.0, fontWeight: FontWeight.w700))
  ],
);

iOS Simulator screenshot

最佳答案

如果您使用 ListTile 小部件作为您的 ListView 项目,您可以添加 dense = true 选项:

ListView(
  children: [
    ListTile(
      dense: true,
      ...
    ),
    ListTile(
      dense: true,
      ...
    ),
  ]
),

关于android - Flutter - 删除 ListView 中项目之间的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52932722/

相关文章:

android - 如何在另一个div中滚动一个div?

android - fragment 中的 MergeAdapter 布局问题

javascript - 在 iPad 上,如何在不显示选项的情况下通过 Javascript 事件在选择元素上设置 focus()?

ios - 旋转设备后动画点会重新定位

dart - 将动画滑动到底部

android - 透明工具栏和状态栏

android - 如何将 adb screenrecord 输出重定向到 pc(windows/linux) 存储

ios - JSQMessage 从未格式化的字符串设置日期属性

flutter - 从flutter的api滚动时如何加载数据

android - 使用Intellij Idea for Flutter时android/app/build.gradle中出现错误