Flutter 如何在颤振中对齐扁平按钮?
我想知道如何在颤振中对齐按钮。我是个新手,对于我目前的代码,我无法插入任何行、列或包装。我想在一个垂直的方式对齐我的按钮,但其当前水平对齐,并给我一个权利溢出256像素显示错误Flutter 如何在颤振中对齐扁平按钮?,flutter,dart,flutter-layout,Flutter,Dart,Flutter Layout,我想知道如何在颤振中对齐按钮。我是个新手,对于我目前的代码,我无法插入任何行、列或包装。我想在一个垂直的方式对齐我的按钮,但其当前水平对齐,并给我一个权利溢出256像素显示错误 return showDialog<void>( context: context, builder: (BuildContext context) {
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: () {},
),
],
);
});
只需将按钮添加到列中即可
只需将按钮添加到列中即可
您可以使用来自动逐行同步
检查下面的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 */
},
),
],
),
));
您可以使用来自动逐行同步
检查下面的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 */
},
),
],
),
));
您好,谢谢您的及时回复!现在它已经对齐了,我如何按左边的按钮?这是我当前的样子,我想把它与第一条语句对齐@永远不要尝试更改crossAxisAlignment:crossAxisAlignment。start@nevertoolateyet尝试将按钮移动到内容。请看我的例子嗨谢谢你的及时回复!现在它已经对齐了,我如何按左边的按钮?这是我当前的样子,我想把它与第一条语句对齐@永远不要尝试更改crossAxisAlignment:crossAxisAlignment。start@nevertoolateyet尝试将按钮移动到内容。请看我的例子
//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 */
},
),
],
),
));