Modals topic

Alerts, sheets, menus and popovers on glass. They are built in the navigator's overlay, so the GlassHost has to be above the navigator (MaterialApp.builder) for them to see the screen they open over.

API What it is
showGlassDialog, GlassAlert, GlassAlertAction An alert that materializes over the screen: blur first, tint last.
showGlassSheet, GlassSheetDetent A sheet from the bottom edge that follows the finger, dragged down to close (unless it is not barrier-dismissible), and pulled up to the whole height with a large detent.
GlassMenuAnchor, GlassMenuItem, GlassMenuController A menu that grows out of the button that opened it.
GlassPopoverAnchor A panel of any content that grows out of its anchor.

An alert

showGlassDialog<void>(
  context: context,
  builder: (BuildContext context) => GlassAlert(
    title: const Text('Delete all notes?'),
    message: const Text('This cannot be undone.'),
    actions: <GlassAlertAction>[
      GlassAlertAction(label: 'Cancel', isDefault: true, onPressed: () => Navigator.pop(context)),
      GlassAlertAction(label: 'Delete', isDestructive: true, onPressed: () => Navigator.pop(context)),
    ],
  ),
);

A sheet only its own buttons close

showGlassSheet<void>(
  context: context,
  barrierDismissible: false, // not the dim, not Escape, not a drag
  showGrabber: false,
  builder: (BuildContext context) => const SignInForm(),
);

A sheet that pulls up to the whole height

showGlassSheet<void>(
  context: context,
  detents: const <GlassSheetDetent>[GlassSheetDetent.medium, GlassSheetDetent.large],
  builder: (BuildContext context) => const NotesList(),
);

At the large detent the sheet is its finish laid on opaquely, by default, and it reads no backdrop: one surface fewer in the capture, and its area out of the atlas. A change inside it is then a retake for the glass around it; a translucent largeFinish keeps it glass.

A menu

GlassMenuAnchor(
  items: <GlassMenuItem>[
    GlassMenuItem(label: 'Rename', onPressed: rename),
    GlassMenuItem(label: 'Delete', isDestructive: true, onPressed: delete),
  ],
  builder: (BuildContext context, GlassMenuController menu) =>
      GlassButton(onPressed: menu.open, child: const Icon(Icons.more_horiz)),
)

Classes

GlassAlert Modals
iOS 26's alert, on glass.
GlassAlertAction Modals
One button of a GlassAlert.
GlassMenuAnchor Modals
A glass menu that grows out of builder's anchor, in the nearest Overlay, which has to be under the GlassHost.
GlassMenuController Modals
What a GlassMenuAnchor's or a GlassPopoverAnchor's builder is given to open and close what it anchors.
GlassMenuItem Modals
One row of a GlassMenuAnchor's menu, kGlassMenuRowHeight tall.
GlassPopoverAnchor Modals
A glass panel of any content that grows out of builder's anchor, as GlassMenuAnchor's menu does, and stays open until a tap outside it or GlassMenuController.close — a popover, for content that is changed in place rather than chosen once.

Constants

kGlassAlertRadius → const double Modals
The alert's corner radius, logical px (iOS 26.5's layer.cornerRadius, a continuous corner).
kGlassAlertWidth → const double Modals
The alert's width, logical px, as iOS 26.5 draws it.
kGlassMenuRadius → const double Modals
A menu's corner radius, logical px (iOS 26.5; the engine's RSuperellipse of 31.5, fitted at 0.23 pt rms). The default of GlassPopoverAnchor.radius.
kGlassMenuRowHeight → const double Modals
The height of one GlassMenuItem, logical px (iOS 26.5: rows of 42, with 10 above the first and below the last).
kGlassMenuWidth → const double Modals
A menu's width, logical px (iOS 26.5's UIMenu from a button, 250 wide). The default of GlassMenuAnchor.width.
kGlassModalDim → const Color Modals
The dim behind an alert and a sheet: black at 0.20, read off iOS 26.5 over a grid of two known levels.
kGlassSheetInset → const double Modals
How far the sheet stands in from the window's sides and bottom, and below the top safe area, logical px (iOS 26.5, the medium detent).
kGlassSheetRadius → const double Modals
The sheet's corner radius, logical px (iOS 26.5; the engine's RSuperellipse of 36, fitted at 0.54 device px rms).

Functions

showGlassDialog<T>({required BuildContext context, required WidgetBuilder builder, bool barrierDismissible = false, String barrierLabel = 'Dismiss', Duration transitionDuration = const Duration(milliseconds: 250)}) → Future<T?> Modals
Shows builder's widget — a GlassAlert, typically — over a dim, centred, in the navigator's overlay.
showGlassSheet<T>({required BuildContext context, required WidgetBuilder builder, GlassFinish? finish, bool showGrabber = true, bool barrierDismissible = true, String barrierLabel = 'Dismiss', BoxConstraints? constraints, List<GlassSheetDetent> detents = const <GlassSheetDetent>[GlassSheetDetent.medium], GlassSheetDetent? initialDetent, ValueChanged<GlassSheetDetent>? onDetentChanged, GlassFinish? largeFinish}) → Future<T?> Modals
Shows builder's widget in a glass sheet rising from the bottom, over a dim. Dragged, it follows the finger; dragged down, it goes past a third of its height or on a flick.

Enums

GlassSheetDetent Modals
The heights a sheet from showGlassSheet rests at — UIKit's UISheetPresentationController.Detent, two of them.