【问题标题】:How to give gaps between FloatingActionButton in Flutter?如何在 Flutter 中的 FloatingActionButton 之间给出间隙?
【发布时间】:2020-08-28 13:53:02
【问题描述】:

我刚刚开始使用颤振,不知道我应该如何在这 2 个 FloatingActionButton 之间留出空隙

 Widget abcde = Container(
  child: Row(
    children: <Widget>[
      Expanded(
          child: Container(
            margin: EdgeInsets.symmetric(horizontal: 20.0),
            child: Row(
              children: <Widget>[
                FloatingActionButton(
                    backgroundColor: Colors.blue,
                    onPressed: (){},
                    child: Icon(Icons.call)),
                FloatingActionButton(
                    backgroundColor: Colors.blue,
                    onPressed: (){},
                    child: Icon(Icons.call)),
              ],
            ),
          )
      ),
    ],
  ),
);

【问题讨论】:

标签: flutter flutter-layout


【解决方案1】:

有很多方法可以解决这个问题:

  1. mainAxisAlignment: MainAxisAlignment.spaceEvenly, 或其他间距选项添加到Row 小部件。
  2. Container 包裹你的FloatingActionButtons 并添加边距/填充,或者直接用Padding/Margin 小部件包裹它们。
  3. 在两者之间添加一个小部件,例如Container/SizedBox/Spacer

我推荐1:

Row(
    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
    children: <Widget>[
      //Fab 1,
      //Fab 2
    ]
),

【讨论】:

  • 太棒了!乐于助人:D
【解决方案2】:

添加大小框。

 FloatingActionButton(
            backgroundColor: Colors.blue,
            onPressed: () {},
            child: Icon(Icons.call)),
        SizedBox(
          width: 10,
        ),
        FloatingActionButton(
            backgroundColor: Colors.blue,
            onPressed: () {},
            child: Icon(Icons.call)),

【讨论】:

  • 如果有用,请标记我的答案。
猜你喜欢
  • 2020-09-02
  • 2020-03-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多