我在堆栈中有小部件,因此我想将按钮栏放置在堆栈的底部中心,但是没有任何作用。该小部件仅粘贴在左侧。这是我的代码。
new Positioned( bottom: 40.0, child: new Container( margin: const EdgeInsets.all(16.0), child: new Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ new Align( alignment: Alignment.bottomCenter, child: new ButtonBar( alignment: MainAxisAlignment.center, children: <Widget>[ new OutlineButton( onPressed: () { Navigator.push( context, new MaterialPageRoute( builder: (context) => new LoginPage())); }, child: new Text( "Login", style: new TextStyle(color: Colors.white), ), ), new RaisedButton( color: Colors.white, onPressed: () { Navigator.push( context, new MaterialPageRoute( builder: (context) => new RegistrationPage())); }, child: new Text( "Register", style: new TextStyle(color: Colors.black), ), ) ], ), ) ], ), ), )
我确实尝试过每个中心对齐,请帮助
删除所有内容,但这:
Align( alignment: Alignment.bottomCenter, child: new ButtonBar( alignment: MainAxisAlignment.center, children: <Widget>[ new OutlineButton( onPressed: () { Navigator.push( context, new MaterialPageRoute( builder: (context) => new LoginPage())); }, child: new Text( "Login", style: new TextStyle(color: Colors.white), ), ), new RaisedButton( color: Colors.white, onPressed: () { Navigator.push( context, new MaterialPageRoute( builder: (context) => new RegistrationPage())); }, child: new Text( "Register", style: new TextStyle(color: Colors.black), ), ) ], ), )
在我的理论中,其他因素Container正在摧毁它。我建议您通过添加以下内容Padding:
Container
Padding
Padding( padding: EdgeInsets.only(bottom: 20.0), child: Align... ),
对于我来说,这似乎比合理得多,Positioned而且我对Column一个孩子的了解还不够。
Positioned
Column