我想知道如何在颤动中对齐按钮。我是不熟悉的新手,对于当前代码,我无法抛出任何行,列或换行。我想以垂直方式对齐按钮,但当前以水平方式对齐按钮,并出现“ RIGHT OVER LOW BY 256 PIXELS”显示错误
return showDialog<void>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
content: Text("You have $counts routes!"),
actions: <Widget>[
new FlatButton(
textColor: Colors.black,
padding:
EdgeInsets.fromLTRB(20, 0, 0, 10),
child: Text(
"This is route 1! \n" +
rList[0] + "\n"),
onPressed: () {},
),
new FlatButton(
textColor: Colors.black,
padding:
EdgeInsets.fromLTRB(20, 0, 0, 10),
child: Text(
"This is your second route! \n" +
rList[1] + "\n"),
onPressed: () {},
),
],
);
});
答案 0 :(得分:2)
只需将按钮添加到Column
actions: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
button,
button
]
)
],
,或者如果您希望按钮位于左侧,请将这些按钮移至content
:
builder: (BuildContext context) {
return AlertDialog(
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text("You have routes!"),
new FlatButton(
textColor: Colors.black,
child: Text(
"This is route 1! \n" +
"\n"),
onPressed: () {},
),
new FlatButton(
textColor: Colors.black,
child: Text(
"This is your second route! \n" +
"\n"),
onPressed: () {},
)
],
),
);
});
答案 1 :(得分:0)
您可以使用ListView自动逐行同步。
在下面的示例中检查ListView。您应该将其粘贴到代码的正文段上。
//some of codes..
body: Padding(
padding: EdgeInsets.only(top: 15, left: 15, right: 15),
child: ListView(
children: <Widget>[
RaisedButton(
child: Text("Confirm"),
color: Colors.lightGreen,
elevation: 5.0,
onPressed: () {
save(1,context);
/* some of codes */
},
),
RaisedButton(
child: Text("Cancel"),
color: Colors.redAccent,
elevation: 5.0,
onPressed: () {
save(0,context);
/* some of codes */
},
),
RaisedButton(
child: Text("Pass"),
color: Colors.yellowAccent,
elevation: 5.0,
onPressed: () {
save(2,context);
/* some of codes */
},
),
],
),
));