首页 > 解决方案 > 孩子们排成一排

问题描述

我使用 Align Widget 将孩子集中在一行中,但它不起作用......我做错了什么?

这是代码:

.... home.dart ....

@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),
)));
}

提前致谢!!

标签: widgetflutterrow

解决方案


请改用 Column/Row 小部件的 mainAxisAlignment / crossAxisAlignment 属性。


推荐阅读