confirm method

  1. @override
Future<ConfirmOutcome> confirm(
  1. ConfirmAction action, {
  2. required String title,
  3. String message = '',
  4. String caption = '',
  5. String confirmLabel = 'OK',
  6. String cancelLabel = 'Cancel',
  7. Map<String, Object?> bound = const {},
  8. 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();
    }
  }
}