我刚刚开始使用颤振,不知道我应该如何在这 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)),
],
),
)
),
],
),
);
有很多方法可以做到这一点:
- 将
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
或其他间距选项添加到Row
微件。 - 用
Container
包裹FloatingActionButtons
并添加边距/填充,或直接用Padding
/Margin
小部件包裹它们。 - 在两者之间添加一个小部件,例如
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)),