多个孩子在颤动

  • 本文关键字:颤动 孩子 flutter
  • 更新时间 :
  • 英文 :


我想在第一个下添加另一个MaterialButton。 我得到了第一个Button,并想添加多个。

body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.only(top: 15, bottom: 0, left: 5, right: 5),
child: MaterialButton(
onPressed: () {},
child: Container(
height: 180,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.grey[300],
borderRadius: BorderRadius.circular(20.0),
),),)

您可以在Expanded小部件中创建按钮,以在Row内均匀分配空间

body: return SingleChildScrollView  (
child: Padding(
padding: EdgeInsets.only(top: 15, bottom: 0, left: 5, right: 5),
child: Row(
children: [
Expanded(
child: MaterialButton(
onPressed: () {},
child: Container(
height: 180,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.grey[300],
borderRadius: BorderRadius.circular(20.0),
),
)
),
),
Expanded(
child: MaterialButton(
onPressed: () {},
child: Container(
height: 180,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.grey[300],
borderRadius: BorderRadius.circular(20.0),
),
)
),
),
Expanded(
child: MaterialButton(
onPressed: () {},
child: Container(
height: 180,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.grey[300],
borderRadius: BorderRadius.circular(20.0),
),
)
),
),
],
),
)
);

如果要添加多个按钮并且要将它们水平对齐,请将按钮括在行小部件中。如果要将它们垂直对齐,请将它们括在列小部件中。

如果要同时水平对齐和垂直对齐,请将父小部件设置为列,并具有行小部件的多个子项,并且该行可以将按钮作为子项

最新更新