Dart 颤振排主轴对准不工作
我试着把两个材料按钮排成一行,中间有均匀的空间。但mainAxisAlignment小部件不起作用。这两个按钮在行的开始处相互粘贴Dart 颤振排主轴对准不工作,dart,flutter,flutter-layout,Dart,Flutter,Flutter Layout,我试着把两个材料按钮排成一行,中间有均匀的空间。但mainAxisAlignment小部件不起作用。这两个按钮在行的开始处相互粘贴 Widget _buildSignInButton() { return Row( children: <Widget>[ Container( child: new Row( mainAxisAlignment: MainAxisAlignment.spaceAround,
Widget _buildSignInButton() {
return Row(
children: <Widget>[
Container(
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
new SignInButton(
onPressed: () {
_googleSignIn();
},
imageUrl: 'assets/images/glogo.png',
),
new SignInButton(
onPressed: () {
_fbSignIn();
},
imageUrl: 'assets/images/fblogo.png',
),
],
),
)
],
);
}
Widget build(BuildContext context) {
return Container(
child: _buildSignInButton()
);
}
Widget\u buildSignInButton(){
返回行(
儿童:[
容器(
孩子:新的一排(
mainAxisAlignment:mainAxisAlignment.spaceAround,
儿童:[
新登录按钮(
已按下:(){
_谷歌签名();
},
imageUrl:'assets/images/glogo.png',
),
新登录按钮(
已按下:(){
_fbSignIn();
},
imageUrl:'assets/images/fblogo.png',
),
],
),
)
],
);
}
小部件构建(构建上下文){
返回容器(
子项:_buildSignInButton()
);
}
尽量简化代码,如下所示:
行(
//儿童:[
//新容器(
//孩子:新的一排(
mainAxisAlignment:mainAxisAlignment.spaceAround,
儿童:[
新文本(“123”),
新文本(“456”),
],
// ),
// ),
// ],
),
或者将容器
替换为扩展的
:
行(
儿童:[
新扩展(
孩子:新的一排(
mainAxisAlignment:mainAxisAlignment.spaceAround,
儿童:[
新文本(“123”),
新文本(“456”),
],
),
),
],
),
有关差异的更多详细信息,请签出文档:您不应在行中换行,您只能使用一行()