【问题标题】:How do I render List and Grid on the same page in flutter?如何在 Flutter 的同一页面上呈现 List 和 Grid?
【发布时间】:2020-03-02 09:32:13
【问题描述】:

我试图在 Flutter 的同一页面上呈现 GridViewListView,其中网格和列表本身不可滚动,但可以作为一个整体滚动。 GridViewListView 将被渲染,但它们应该在页面上具有不连续的网格和列表分布。

提前致谢!

【问题讨论】:

  • “在同一页面上渲染列表和网格”是什么意思?你能详细说明一下吗?提供一个视觉示例将不胜感激。

标签: flutter dart


【解决方案1】:

primary: falseshrinkWrap: true 用于GridView

return ListView(
  children: <Widget>[
    Container(
      height: 75,
      color: Colors.green,
      margin: const EdgeInsets.all(25),
    ),
    GridView.count(
      primary: false,
      shrinkWrap: true,
      crossAxisCount: 3,
      children: List<Widget>
        .generate(10, (_) => Container(
            color: Colors.red,
            margin: const EdgeInsets.all(25),
      )),
    ),
  ],
);

【讨论】:

  • 为了获得更好的答案,您应该解释他们每个人的作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-05-29
  • 2014-02-20
  • 1970-01-01
  • 1970-01-01
  • 2018-10-20
  • 1970-01-01
  • 2019-06-01
相关资源
最近更新 更多