我想在警报对话框中居中放置一个平面按钮 我尝试了以下代码,但无法正常工作
actions: <Widget>[
Container(
alignment: Alignment.center,
child: FlatButton(
child: Text('something'),
onPressed: (){},
),
),
],
答案 0 :(得分:0)
怎么样?
AlertDialog(
title: FlatButton(
child: Text('something'),
onPressed: () {},
),
);
或
AlertDialog(
content: FlatButton(
child: Text('something'),
onPressed: () {},
),
);
答案 1 :(得分:0)
使用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();
},
)
],
);