showConfirmationDialog function
彈出一個確認對話框 以便用戶確認操作
Implementation
Future<bool?> showConfirmationDialog(
BuildContext context, {
Widget? title,
Widget? child,
}) {
return showDialog<bool>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: title,
content: SingleChildScrollView(
child: child,
),
actions: <Widget>[
TextButton(
child: Text(MaterialLocalizations.of(context).okButtonLabel),
onPressed: () => Navigator.of(context).pop(true),
),
TextButton(
child: Text(MaterialLocalizations.of(context).cancelButtonLabel),
onPressed: () => Navigator.of(context).pop(false),
),
],
);
},
);
}