Flutter AlertDialog对话框是一个警报对话框,会通知用户需要确认的情况。警报对话框具有可选标题和可选的操作列表。
参数详解
属性 | 说明 |
title | 标题 |
titlePadding | 标题内边距 |
titleTextStyle | 标题文字样式 |
content | 内容 |
contentPadding | 内容 内边距 默认EdgeInsets.fromLTRB(24.0, 20.0, 24.0, 24.0), |
contentTextStyle | 内容文字样式 |
actions | 对话框下边的Widget组件集合 |
backgroundColor | 背景颜色 |
elevation | 阴影高度 |
semanticLabel | |
shape | 形状 |
代码示例
showDialog(
context: context,
barrierDismissible: true, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: Text('我是标题'),
content:Text('我是content'),
actions:<Widget>[
FlatButton(
child: Text('YES'),
onPressed: (){
print('yes...');
Navigator.of(context).pop();
},
),
FlatButton(
child: Text('NO'),
onPressed: (){
print('no...');
Navigator.of(context).pop();
},
),
],
backgroundColor:Colors.yellowAccent,
elevation: 20,
semanticLabel:'哈哈哈哈',
// 设置成 圆角
shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
);
},
);