showAlert method
实现对话框 >>>
Implementation
Future showAlert({
required String title,
String subTitle = '',
Color titleColor = Colors.black,
Color subTitleColor = Colors.grey,
double titleFontSize = 20,
double subTitleFontSize = 16,
required List<DialogAction> actions,
bool barrierDismissible = true,
}) async {
return showDialog(
context: this,
builder: (ctx) {
return AlertDialog(
title: Text(
title,
style: TextStyle(color: titleColor, fontSize: titleFontSize),
),
content: Text(
subTitle,
style:
TextStyle(color: subTitleColor, fontSize: subTitleFontSize),
),
actions: actions.map((e) {
return InkWell(
child: Container(
height: 35,
width: 110,
padding: EdgeInsets.fromLTRB(8, 4, 8, 4),
alignment: Alignment.center,
decoration: BoxDecoration(
color: e.color,
borderRadius: BorderRadius.circular(4),
),
child: Text(
e.title,
style: TextStyle(color: Colors.white, fontSize: 16),
),
margin: EdgeInsets.all(8),
),
onTap: () {
if (e.action != null) {
e.action!();
}
if (e.close) {
Navigator.of(ctx).pop();
}
});
}).toList(),
);
},
barrierDismissible: barrierDismissible);
}