【问题标题】:How to edit an item using GridView widget in flutter?如何在颤动中使用 GridView 小部件编辑项目?
【发布时间】:2020-12-08 04:17:35
【问题描述】:

,我在 GridView 工作,但我只需要更改一个项目或一些项目的布局,而不是全部,例如 (height or width..etc) 。 childAspectRatio 选项它还会更改所有项目,所以这是我需要更改我选择的特定项目的问题,我该怎么做? .

代码:

class StaggeredGridExample extends StatefulWidget {
  @override
  _StaggeredGridExampleState createState() => _StaggeredGridExampleState();
}

class _StaggeredGridExampleState extends State<StaggeredGridExample> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: GridView.count(
      crossAxisCount: 2,
      childAspectRatio: 16/9,
      children: [
        Container(
          color: Colors.green,
          child: Icon(Icons.translate),
        ),
        Container(
          color: Colors.blueGrey,
          child: Icon(Icons.shop),
        ),
        Container(
          color: Colors.deepOrangeAccent,
          child: Icon(Icons.date_range),
        ),
        Container(
          color: Colors.cyan,
          child: Icon(Icons.radio),
        ),
        Container(
          color: Colors.brown,
          child: Icon(Icons.favorite_border),
        ),
      ],
    ));
  }
}

谢谢!

【问题讨论】:

    标签: flutter flutter-layout flutter-dependencies flutter-web flutter-animation


    【解决方案1】:

    gridview 要求所有项目的大小相同。如果你想定制和使用不同的尺寸,你需要使用插件。

    网址链接:https://pub.dev/packages/flutter_staggered_grid_view

    【讨论】:

      猜你喜欢
      • 2022-01-03
      • 2019-09-15
      • 2019-07-25
      • 1970-01-01
      • 2021-05-19
      • 1970-01-01
      • 1970-01-01
      • 2020-12-03
      • 1970-01-01
      相关资源
      最近更新 更多