showGlassActionSheet<T> function
Future<T?>
showGlassActionSheet<T>({
- required BuildContext context,
- String? title,
- String? message,
- required List<
GlassActionSheetAction> actions, - String cancelLabel = 'Cancel',
- bool showCancelButton = true,
- bool barrierDismissible = true,
- LiquidGlassSettings? settings,
- GlassQuality? quality,
A glass morphism action sheet following iOS 26 liquid glass design.
This action sheet provides an iOS-style bottom action sheet with:
- iOS 26 liquid glass backdrop effect
- Bottom-anchored action list
- Destructive action styling (red text/icon)
- Cancel button always at bottom with separator
- Tap outside to dismiss
- Slide-up animation
- Optional title and message
Usage
Basic Action Sheet
showGlassActionSheet(
context: context,
title: 'Delete Photo?',
message: 'This action cannot be undone',
actions: [
GlassActionSheetAction(
label: 'Delete',
style: GlassActionSheetStyle.destructive,
onPressed: () {
// Delete logic
Navigator.pop(context);
},
),
],
);
Multiple Actions
showGlassActionSheet(
context: context,
title: 'Choose Action',
actions: [
GlassActionSheetAction(
label: 'Save to Photos',
icon: Icon(CupertinoIcons.photo),
onPressed: () => save(),
),
GlassActionSheetAction(
label: 'Share',
icon: Icon(CupertinoIcons.share),
onPressed: () => share(),
),
GlassActionSheetAction(
label: 'Delete',
icon: Icon(CupertinoIcons.delete),
style: GlassActionSheetStyle.destructive,
onPressed: () => delete(),
),
],
);
Custom Cancel Label
showGlassActionSheet(
context: context,
title: 'Select Option',
actions: [...],
cancelLabel: 'Dismiss', // Custom cancel button text
);
No Cancel Button
showGlassActionSheet(
context: context,
title: 'Select Option',
actions: [...],
showCancelButton: false,
);
iOS 26 / iOS 27 vs classic presentation
GlassStyle.ios26/GlassStyle.ios27(default): matches the nativeUIAlertControlleraction sheet on iOS 26/27 — the same 320 pt platter as GlassDialog, centred on screen, with a leading-aligned header, stacked filled capsule actions and Cancel inside the same platter.GlassStyle.classic: the original bottom-anchored sheet with a separate Cancel card.
Design principles (classic)
- Bottom-anchored: Always slides up from bottom
- Grouped layout: Actions in one card, cancel button separated
- Destructive styling: Red text for dangerous actions
- Glass backdrop: Liquid glass effect on action cards
- Modal dismissal: Tap outside or cancel to dismiss
- Safe area aware: Respects bottom safe area
Differences from GlassSheet
- GlassActionSheet: Predefined action list (like iOS UIAlertController)
- GlassSheet: Custom content (like iOS UISheetPresentationController)
Use showGlassActionSheet when you need a simple action picker. Use GlassSheet when you need custom content or forms.
Implementation
Future<T?> showGlassActionSheet<T>({
required BuildContext context,
String? title,
String? message,
required List<GlassActionSheetAction> actions,
String cancelLabel = 'Cancel',
bool showCancelButton = true,
bool barrierDismissible = true,
LiquidGlassSettings? settings,
GlassQuality? quality,
}) {
final capturedGlassTheme = GlassTheme.maybeOf(context)?.data;
final capturedCupertinoTheme = CupertinoTheme.of(context);
final style = GlassThemeHelpers.resolveStyle(context);
final isDark = GlassTheme.brightnessOf(context) == Brightness.dark;
Widget withAmbientThemes(Widget sheet) {
sheet = CupertinoTheme(
data: capturedCupertinoTheme,
child: sheet,
);
if (capturedGlassTheme != null) {
sheet = GlassTheme(
data: capturedGlassTheme,
child: sheet,
);
}
return sheet;
}
if (style != GlassStyle.classic) {
// ios26 / ios27: the native action sheet is the alert platter with
// stacked actions (Cancel included), centred on screen.
return pushGlassAlertRoute<T>(
context: context,
barrierDismissible: barrierDismissible,
barrierColor: glassAlertBarrierColor(isDark: isDark),
builder: (modalContext) {
void dismiss() => Navigator.of(modalContext).pop();
return withAmbientThemes(
GlassAlertPlatter(
title: title,
message: message,
settings: settings,
quality: quality,
forceStacked: true,
semanticsRole: SemanticsRole.dialog,
actions: [
for (final action in actions)
GlassAlertPlatterAction(
label: action.label,
icon: action.icon,
isDestructive:
action.style == GlassActionSheetStyle.destructive,
onPressed: () {
action.onPressed();
if (action.style != GlassActionSheetStyle.cancel) {
dismiss();
}
},
),
if (showCancelButton)
GlassAlertPlatterAction(
label: cancelLabel,
onPressed: dismiss,
),
],
),
);
},
);
}
return showCupertinoModalPopup<T>(
context: context,
barrierDismissible: barrierDismissible,
barrierColor: GlassDefaults.barrierColor,
builder: (modalContext) => withAmbientThemes(
_GlassActionSheetContent(
title: title,
message: message,
actions: actions,
cancelLabel: cancelLabel,
showCancelButton: showCancelButton,
settings: settings,
quality: quality,
),
),
);
}