show static method

void show(
  1. BuildContext context, {
  2. required String title,
  3. String? message,
  4. String confirmLabel = 'Confirm',
  5. String cancelLabel = 'Cancel',
  6. void onResult(
    1. bool confirmed
    )?,
})

Show a confirmation dialog via DialogStack.

Pushes a DialogConfirm onto the nearest DialogStack and waits for the user's response.

Implementation

static void show(
  BuildContext context, {
  required String title,
  String? message,
  String confirmLabel = 'Confirm',
  String cancelLabel = 'Cancel',
  void Function(bool confirmed)? onResult,
}) {
  final stack = DialogStack.of(context);
  stack.push(
    DialogConfirm(
      title: title,
      message: message,
      confirmLabel: confirmLabel,
      cancelLabel: cancelLabel,
      onConfirm: () {
        stack.pop();
        onResult?.call(true);
        return null;
      },
      onCancel: () {
        stack.pop();
        onResult?.call(false);
        return null;
      },
    ),
  );
}