我正在使用Align Widget将孩子排成一行,但是它不起作用...我在做什么错了?
这是代码:
... 飞镖 ....
@override
Widget build(BuildContext context){
_context = context;
return new Scaffold(
appBar: new AppBar(title: Text("MiniCon")),
body: new Container(child: new Column(children:[
new Align(alignment:Alignment.center,child:new Row(children:[
_commons.makeEditText("Ahorro Real", grey, false),
_commons.makeEditText("Ahorro Actual", black, true),
_commons.makeEditText("Gastos", black, true)
])),
new Row(children:[
_commons.makeEditText("Ahorro Real", grey, false)
])
])));
}
... _commons.dart ....
Widget makeEditText(String label, Color labelColor, bool enabled) {
return
new Padding(padding:EdgeInsets.all(2.5), child:
new Container(decoration:
new BoxDecoration(border:
new Border.all(width:2.0)),padding: new
new EdgeInsets.all(10.0),width:110.0,child:
new TextField(enabled: enabled,
style: TextStyle(color: labelColor),
decoration: new InputDecoration(
labelStyle: TextStyle(fontSize: 15.0), labelText: label),
)));
}
提前谢谢!
答案 0 :(得分:0)
改用Column / Row小部件的mainAxisAlignment / crossAxisAlignment属性。
答案 1 :(得分:0)
这使行居中
body: Container(
child: Column(children: [
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
makeEditText("Ahorro Real", Colors.grey, false),
makeEditText("Ahorro Actual", Colors.black, true),
makeEditText("Gastos", Colors.green, true)
]),
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [makeEditText("Ahorro Real", Colors.red, false)])
]),
),