Flutter 如何将“颤振”中的“警报”对话框上的操作按钮居中?
我想在警报对话框上居中放置一个平面按钮 我尝试了以下代码,但不起作用Flutter 如何将“颤振”中的“警报”对话框上的操作按钮居中?,flutter,Flutter,我想在警报对话框上居中放置一个平面按钮 我尝试了以下代码,但不起作用 actions: <Widget>[ Container( alignment: Alignment.center, child: FlatButton( child: Text('something'), onPressed: (){}, ),
actions: <Widget>[
Container(
alignment: Alignment.center,
child: FlatButton(
child: Text('something'),
onPressed: (){},
),
),
],
操作:[
容器(
对齐:对齐.center,
孩子:扁平按钮(
child:Text(“某物”),
按下:(){},
),
),
],
这个怎么样
AlertDialog(
title: FlatButton(
child: Text('something'),
onPressed: () {},
),
);
或
使用
CupertinoAlertDialog
而不是AlertDialog
这要简单得多
CupertinoAlertDialog(
title: Text("Alert !",
style: AppTheme.normalTextStyle()
.copyWith(fontWeight: FontWeight.bold, fontSize: 15)),
content: Text(
"Are you sure you want to logout?",
style: AppTheme.normalTextStyle(),
),
actions: <Widget>[
FlatButton(
child: Text("Yes", style: AppTheme.normalTextStyle()),
onPressed: () {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => LogInScreen()),
(Route<dynamic> route) => false);
},
),
FlatButton(
child: Text("No", style: AppTheme.normalTextStyle()),
onPressed: () {
Navigator.of(context).pop();
},
)
],
);
CupertinoAlertDialog(
标题:文本(“警报!”,
样式:AppTheme.normalTextStyle()
.copyWith(fontWeight:fontWeight.bold,fontSize:15)),
内容:文本(
“您确定要注销吗?”,
样式:AppTheme.normalTextStyle(),
),
行动:[
扁平按钮(
子项:文本(“是”,样式:AppTheme.normalTextStyle()),
已按下:(){
Navigator.of(context).pushandremoveintil(
MaterialPage路由(生成器:(上下文)=>LogInScreen()),
(路由)=>false);
},
),
扁平按钮(
子项:文本(“否”,样式:AppTheme.normalTextStyle()),
已按下:(){
Navigator.of(context.pop();
},
)
],
);
CupertinoAlertDialog(
title: Text("Alert !",
style: AppTheme.normalTextStyle()
.copyWith(fontWeight: FontWeight.bold, fontSize: 15)),
content: Text(
"Are you sure you want to logout?",
style: AppTheme.normalTextStyle(),
),
actions: <Widget>[
FlatButton(
child: Text("Yes", style: AppTheme.normalTextStyle()),
onPressed: () {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => LogInScreen()),
(Route<dynamic> route) => false);
},
),
FlatButton(
child: Text("No", style: AppTheme.normalTextStyle()),
onPressed: () {
Navigator.of(context).pop();
},
)
],
);