show<T> static method

Future<T?> show<T>({
  1. required BuildContext context,
  2. required List<GlassDialogAction> actions,
  3. String? title,
  4. String? message,
  5. Widget? content,
  6. LiquidGlassSettings? settings,
  7. GlassQuality? quality,
  8. bool barrierDismissible = false,
  9. Color? barrierColor,
  10. double? maxWidth,
  11. LiquidShape? shape,
  12. LiquidShape? actionShape,
  13. TextStyle? actionTextStyle,
})

Shows a glass dialog.

Returns a Future that resolves to the value (if any) passed to Navigator.pop when the dialog is dismissed.

Parameters:

  • context: Build context for showing the dialog
  • title: Title text (optional)
  • message: Message text (optional)
  • content: Custom content widget (optional)
  • actions: Action buttons (required, 1-3 actions)
  • settings: Glass effect settings (null uses defaults)
  • quality: Rendering quality (null inherits from the ambient layer or GlassTheme, falling back to standard)
  • barrierDismissible: Whether tapping outside dismisses (default: false)
  • barrierColor: Color of the modal barrier (defaults to the native dimming on ios26/ios27, and the Cupertino modal barrier color on classic)
  • maxWidth: Maximum width of dialog (null follows the active style: 320 on ios26/ios27, 280 on classic)
  • shape: Custom dialog shape (null uses the style default)
  • actionShape: Custom action button shape (null uses the style default)
  • actionTextStyle: Merged over action label styles (role colors still apply)

Example:

final result = await GlassDialog.show<bool>(
  context: context,
  title: 'Confirm',
  message: 'Are you sure?',
  actions: [
    GlassDialogAction(
      label: 'Cancel',
      onPressed: () => Navigator.pop(context, false),
    ),
    GlassDialogAction(
      label: 'Confirm',
      onPressed: () => Navigator.pop(context, true),
    ),
  ],
);

Implementation

static Future<T?> show<T>({
  required BuildContext context,
  required List<GlassDialogAction> actions,
  String? title,
  String? message,
  Widget? content,
  LiquidGlassSettings? settings,
  GlassQuality? quality,
  bool barrierDismissible = false,
  Color? barrierColor,
  double? maxWidth,
  LiquidShape? shape,
  LiquidShape? actionShape,
  TextStyle? actionTextStyle,
}) {
  final capturedGlassTheme = GlassTheme.maybeOf(context)?.data;
  final capturedCupertinoTheme = CupertinoTheme.of(context);
  final isNative =
      GlassThemeHelpers.resolveStyle(context) != GlassStyle.classic;
  final isDark = GlassTheme.brightnessOf(context) == Brightness.dark;
  final resolvedBarrierColor = barrierColor != null
      ? CupertinoDynamicColor.resolve(barrierColor, context)
      : (isNative
          ? glassAlertBarrierColor(isDark: isDark)
          : CupertinoDynamicColor.resolve(
              kCupertinoModalBarrierColor,
              context,
            ));
  return pushGlassAlertRoute<T>(
    context: context,
    barrierDismissible: barrierDismissible,
    barrierColor: resolvedBarrierColor,
    builder: (dialogContext) {
      Widget dialog = GlassDialog(
        title: title,
        message: message,
        content: content,
        actions: actions,
        settings: settings,
        quality: quality,
        maxWidth: maxWidth,
        shape: shape,
        actionShape: actionShape,
        actionTextStyle: actionTextStyle,
      );
      dialog = CupertinoTheme(
        data: capturedCupertinoTheme,
        child: dialog,
      );
      if (capturedGlassTheme != null) {
        dialog = GlassTheme(
          data: capturedGlassTheme,
          child: dialog,
        );
      }
      return dialog;
    },
  );
}