confirm method
The title
argument is used to title of alert dialog.
The content
argument is used to content of alert dialog.
The textOK
argument is used to text for 'OK' Button of alert dialog.
The textCancel
argument is used to text for 'Cancel' Button of alert dialog.
The canPop
argument is canPop
of PopScope.
The onPopInvoked
argument is onPopInvoked
of PopScope.
Returns a Future<bool>.
Implementation
Future<bool> confirm(
dynamic content, {
dynamic title,
dynamic textOK,
dynamic textCancel,
bool canPop = false,
void Function(bool, dynamic)? onPopInvoked,
}) async {
final bool? isConfirm = await showDialog<bool>(
context: this,
barrierDismissible: canPop,
builder: (BuildContext context) {
textOK ??= context.translations.ok;
textCancel ??= context.translations.cancel;
content ??= "${context.materialLocalizations.continueButtonLabel}?";
return PopScope(
canPop: canPop,
onPopInvokedWithResult: onPopInvoked,
child: AlertDialog(
title: forceWidget(title),
content: SingleChildScrollView(
child: forceWidget(content),
),
actions: <Widget>[
TextButton(
child: forceWidget(textOK)!,
onPressed: () => context.pop(true),
),
TextButton(
child: forceWidget(textCancel)!,
onPressed: () => context.pop(false),
),
],
),
);
},
);
return isConfirm ?? false;
}