showAlertDialog static method
dynamic
showAlertDialog(
- BuildContext context,
- String title,
- String message,
- String okText,
- String cancelText, {
- dynamic onOkPressed,
- dynamic onCancelPressed,
- dynamic okCloseDialog = true,
显示弹出框
Implementation
static showAlertDialog(BuildContext context, String title, String message, String okText, String cancelText,
{onOkPressed, onCancelPressed, okCloseDialog = true}) {
showDialog<Null>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: Text(title),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text(message),
],
),
),
actions: <Widget>[
TextButton(
child: Text(cancelText),
onPressed: () {
if (null != onCancelPressed) {
onCancelPressed();
}
Navigator.of(context).pop();
},
),
TextButton(
child: Text(okText),
onPressed: () {
if (null != onOkPressed) {
onOkPressed();
}
if (null != okCloseDialog && okCloseDialog) {
Navigator.of(context).pop();
}
},
),
],
);
},
).then((val) {
print(val);
});
}