【问题标题】:Positioning Grid-View in Flutter在 Flutter 中定位 Grid-View
【发布时间】:2020-09-27 14:49:52
【问题描述】:

我是 Flutter 的新手。我有一个带有多个浮动操作按钮的网格视图。有什么方法可以将我的网格视图小部件定位在 y 轴上。我想要屏幕中间的网格视图小部件。 一般如何在颤振中定位布局?

感谢您的帮助


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: GridView.count(
          padding: const EdgeInsets.all(20),
          crossAxisSpacing: 15,
          mainAxisSpacing: 20,
          crossAxisCount: 4,
          children: <Widget>[
            FloatingActionButton(
              onPressed: () {
                press_1_button();
              },
              child: Text("1"),)
            ,FloatingActionButton(
              onPressed: (){
                press_2_button();
              },
            child: Text("2"),)

            ,FloatingActionButton(
              onPressed: () {
                press_3_button();
              },
              child: Text("3"),)
            ,FloatingActionButton(
              onPressed: (){
                press_4_button();
              },
              child: Text("4"),)

            ,FloatingActionButton(
              onPressed: () {
                press_5_button();
              },
              child: Text("5"),)
            ,FloatingActionButton(
              onPressed: (){
                press_6_button();
              },
              child: Text("6"),)

            ,FloatingActionButton(
              onPressed: () {
                press_7_button();
              },
              child: Text("7"),)
            ,FloatingActionButton(
              onPressed: (){
                press_8_button();
              },
              child: Text("8"),)


            ,FloatingActionButton(
              onPressed: () {
                press_9_button();
              },
              child: Text("9"),)
          ],
        ),
      ),
    );
  }
}

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    尝试用填充包裹它

    Padding(
      padding:const EdgeInsets.only(top:20.0),
      child:GridView(...)
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-26
      相关资源
      最近更新 更多