confirm method
Future<ConfirmOutcome>
confirm(
- ConfirmAction action, {
- required String title,
- String message = '',
- String caption = '',
- String confirmLabel = 'OK',
- String cancelLabel = 'Cancel',
- Map<
String, Object?> bound = const {}, - Json params = const {},
override
Asks to confirm; text, params and bound (the action's variables)
evaluated.
Implementation
@override
Future<ConfirmOutcome> confirm(ConfirmAction action,
{required String title,
String message = '',
String caption = '',
String confirmLabel = 'OK',
String cancelLabel = 'Cancel',
Map<String, Object?> bound = const {},
Json params = const {}}) async {
final c = _context;
if (c == null) return const ConfirmOutcome(false);
final request = ConfirmRequest(
action,
title: title,
caption: caption,
message: message,
confirmLabel: confirmLabel,
cancelLabel: cancelLabel,
bound: bound,
params: params,
);
// Asked from a menu's line: the menu is out of sight while the question
// is (its line's chain, and the `close` after it, still run in it).
final menu = ModalRoute.of(c);
final hidden = menu is PopupRoute && menu.settings.name == popoverRouteName && menu.isCurrent;
if (hidden) menu.offstage = true;
try {
return await _confirm(c, action, request, bound);
} finally {
// Shown again if the chain leaves it open; a menu that closed is gone.
if (hidden) {
SchedulerBinding.instance.addPostFrameCallback((_) {
if (menu.isActive) menu.offstage = false;
});
SchedulerBinding.instance.scheduleFrame();
}
}
}