show static method

Future<void> show(
  1. BuildContext context, {
  2. required String title,
  3. String? message,
  4. String buttonLabel = 'OK',
  5. CmdCallback? onDismiss,
})

Show an alert dialog.

The dialog is pushed via Navigator.showDialog and dismissed when the user presses Enter, Escape, or clicks the OK button.

Returns a Future that completes when the dialog is dismissed.

Implementation

static Future<void> show(
  BuildContext context, {
  required String title,
  String? message,
  String buttonLabel = 'OK',
  CmdCallback? onDismiss,
}) {
  return Navigator.of(context)
      .showDialog<void>(
        builder: (ctx) => DialogAlert(
          title: title,
          message: message,
          buttonLabel: buttonLabel,
          onDismiss: () {
            Navigator.of(ctx).pop();
            onDismiss?.call();
            return null;
          },
        ),
      )
      .then((_) => null);
}