showAlert static method
Implementation
static void showAlert(BuildContext context,
{String? title, String? content, Function? onConfirm}) {
showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
title: Text(
'$title',
style: TextStyle(fontSize: 22.0, color: Colors.black),
),
titleTextStyle: TextStyle(fontStyle: FontStyle.normal),
content: Text(
'$content',
style: TextStyle(fontSize: 14.0),
),
actions: <Widget>[
TextButton(
child: Text('取消'),
onPressed: () => Navigator.pop(context, 'Cancel'),
),
TextButton(
child: Text('确定'),
onPressed: () => Navigator.pop(context, 'OK'),
),
],
),
).then<String>((returnVal) async {
if (returnVal != null) {
if (returnVal == 'OK') {
if (onConfirm != null) onConfirm();
}
}
return '';
});
}