【问题标题】:Flutter 3 Column grid with grid widgetFlutter 3 带有网格小部件的列网格
【发布时间】:2020-10-18 17:17:48
【问题描述】:

我是 Flutter 初学者,正在尝试创建一个具有 3 列网格的页面,该网格跨越多行(如果超过 3 个项目,基本上应该换行到下一行)。 [![在此处输入图像描述][1]][1]。正如您在设计中看到的,屏幕中还有其他小部件。我尝试使用 Grid Widget,但它在小部件容器内滚动,我不想要内部滚动,但它应该与页面一起滚动。

Widget build(BuildContext context) {
return GridView.count(
  crossAxisCount: 3,
  children: List.generate(7, (index) {
    return Center(
      child: Text(
        'Item $index',
        style: Theme.of(context).textTheme.headline5,
      ),
    );
  }),
);

}

【问题讨论】:

    标签: flutter


    【解决方案1】:

    你必须在你的gridview中设置primary: false

    Widget build(BuildContext context) {
    return GridView.count(
      primary: false,
      crossAxisCount: 3,
      children: List.generate(7, (index) {
        return Center(
          child: Text(
            'Item $index',
            style: Theme.of(context).textTheme.headline5,
          ),
        );
      }),
    );
    }
    

    欲了解更多信息:check docs

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-04
      • 2021-03-22
      相关资源
      最近更新 更多