如何在一行中添加 space (Flutter)?
How to add space in one row (Flutter)?
我是初学者。我有一排和 2 个按钮。我想在它们之间添加 space ,例如填充、边距、容器或其他东西。我尝试了很多其他问题的解决方案,但都不适合我。
我的代码:
Row(
children: <Widget>[
Expanded(
child: ElevatedButton(
onPressed: () {},
child: Text("Scan"),
)),
Expanded(
child: ElevatedButton(
onPressed: () {},
child: Text("Manually"),
)),
],
);
使用SizedBox
Row(
children: <Widget>[
Expanded(
child: ElevatedButton(
onPressed: () {},
child: Text("Scan"),
)),
SizedBox(
width: 100,
),
Expanded(
child: ElevatedButton(
onPressed: () {},
child: Text("Manually"),
)),
],
);
您可以在要添加的按钮周围添加填充 space
Row(
children: <Widget>[
Expanded(
child: ElevatedButton(
onPressed: () {},
child: Text("Scan"),
)),
SizedBox(
width: 100,
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(left:8.0),
child: ElevatedButton(
onPressed: () {},
child: Text("Manually"),
),
)),
],
),
我是初学者。我有一排和 2 个按钮。我想在它们之间添加 space ,例如填充、边距、容器或其他东西。我尝试了很多其他问题的解决方案,但都不适合我。
我的代码:
Row(
children: <Widget>[
Expanded(
child: ElevatedButton(
onPressed: () {},
child: Text("Scan"),
)),
Expanded(
child: ElevatedButton(
onPressed: () {},
child: Text("Manually"),
)),
],
);
使用SizedBox
Row(
children: <Widget>[
Expanded(
child: ElevatedButton(
onPressed: () {},
child: Text("Scan"),
)),
SizedBox(
width: 100,
),
Expanded(
child: ElevatedButton(
onPressed: () {},
child: Text("Manually"),
)),
],
);
您可以在要添加的按钮周围添加填充 space
Row(
children: <Widget>[
Expanded(
child: ElevatedButton(
onPressed: () {},
child: Text("Scan"),
)),
SizedBox(
width: 100,
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(left:8.0),
child: ElevatedButton(
onPressed: () {},
child: Text("Manually"),
),
)),
],
),