如何在 Flutter 中给出浮动动作按钮之间的间隙?



我刚刚开始使用颤振,不知道我应该如何在这 2 个浮动动作按钮之间给出间隙

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)),
],
),
)
),
],
),
);

有很多方法可以做到这一点:

  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
]
),

添加 SsizeBox。

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

最新更新