showAlertDialog method
Future<bool?>
showAlertDialog(
- BuildContext context, {
- String? title,
- Widget? content,
- String confirmButtonText = 'Ok',
- String? cancelButtonText,
Implementation
Future<bool?> showAlertDialog(BuildContext context,
{String? title,
Widget? content,
String confirmButtonText = 'Ok',
String? cancelButtonText}) {
var titleWidget = title == null ? null : Text(title);
var contentWidget = content == null ? null : content;
var popupActions = <Widget>[];
if (cancelButtonText != null) {
popupActions.add(TextButton(
child: Text(cancelButtonText),
onPressed: () {
Navigator.of(context).pop(false);
},
));
}
popupActions.add(TextButton(
child: Text(confirmButtonText),
onPressed: () {
Navigator.of(context).pop(true);
},
));
return showDialog<bool?>(
context: context,
barrierDismissible: false,
builder: (_) => AlertDialog(
actions: popupActions,
title: titleWidget,
content: contentWidget,
));
}