GlassToast class

A glass morphism toast/snackbar following iOS 26 liquid glass design.

GlassToast provides temporary, non-intrusive notifications with:

  • iOS 26 liquid glass backdrop effect
  • Auto-dismiss with configurable duration
  • Slide-in/slide-out animations with spring physics
  • Swipe-to-dismiss gesture
  • Queue management for multiple toasts
  • Semantic toast types (success, error, info, warning)
  • Optional action button
  • Configurable positioning (top, center, bottom)

Usage

Basic Success Toast

GlassToast.show(
  context,
  message: 'Settings saved successfully',
  type: GlassToastType.success,
);

Error Toast with Action

GlassToast.show(
  context,
  message: 'Failed to save changes',
  type: GlassToastType.error,
  action: GlassToastAction(
    label: 'Retry',
    onPressed: () => saveChanges(),
  ),
);

Info Toast at Top

GlassToast.show(
  context,
  message: 'New message received',
  type: GlassToastType.info,
  icon: Icon(CupertinoIcons.envelope),
  position: GlassToastPosition.top,
);

Warning Toast with Custom Duration

GlassToast.show(
  context,
  message: 'Storage space running low',
  type: GlassToastType.warning,
  duration: Duration(seconds: 5),
);

Custom Toast with Manual Dismiss

GlassToast.show(
  context,
  message: 'Processing...',
  type: GlassToastType.neutral,
  duration: Duration.zero, // Won't auto-dismiss
  dismissible: true, // Can be swiped away
);

iOS 26 Design Principles

  • Pill-shaped morphology: Rounded capsule with liquid glass backdrop
  • Subtle animations: Spring physics for natural motion (iOS 26 standard)
  • Non-blocking: Floats above content without modal barrier
  • Contextual colors: Semantic colors for different message types
  • Haptic feedback: Provides tactile response on appearance (if supported)
  • Adaptive positioning: Respects safe areas and keyboard

Queue Management

Toasts are automatically queued when multiple are shown simultaneously. The queue ensures:

  • One toast visible at a time
  • Smooth transitions between toasts
  • Proper cleanup of dismissed toasts

Accessibility

  • Uses Semantics with liveRegion: true for screen reader announcements
  • Semantic labels for action buttons
  • High contrast mode support via theme
  • Respects reduce motion preferences for animations
Inheritance
Available extensions

Constructors

GlassToast({required String message, Key? key, Widget? icon, GlassToastType type = GlassToastType.success, GlassToastPosition position = GlassToastPosition.bottom, GlassToastAction? action, bool dismissible = true, VoidCallback? onDismissed, LiquidGlassSettings? settings, GlassQuality? quality})
Creates a glass toast notification.
const

Properties

action → GlassToastAction?
Optional action button
final
dismissible → bool
Whether the toast can be dismissed by swiping
final
hashCode → int
The hash code for this object.
no setterinherited
icon → Widget?
Optional icon widget to display before the message
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
message → String
The message text to display
final
onDismissed → VoidCallback?
Callback when the toast is dismissed
final
position → GlassToastPosition
Position where the toast should appear
final
quality → GlassQuality?
Rendering quality (overrides theme)
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
settings → LiquidGlassSettings?
Custom glass settings (overrides theme)
final
type → GlassToastType
Visual style and semantic meaning of the toast
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<GlassToast>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
glassContextMenu({Key? key, required List<Widget> actions, WidgetBuilder? previewBuilder, bool enabled = true, bool enableHaptics = true, double borderRadius = 32.0, double? previewBorderRadius, double rowBorderRadius = 16.0, BorderRadius? rowCorners, Color? originSlotColor, Color? backgroundColor, LiquidGlassSettings? settings, GlassQuality? quality, double backdropBlur = 0.0, Color? barrierColor, double menuWidth = 250.0, VoidCallback? onOpened, VoidCallback? onDismissed, Duration longPressDuration = const Duration(milliseconds: 700)}) → Widget

Available on Widget, provided by the GlassContextMenuExtension extension

Wraps this widget in a GlassContextMenu displaying actions on long-press or right-click.
glassFullScreenCover({required bool isPresented, VoidCallback? onDismiss, required WidgetBuilder content, bool enableSwipeToDismiss = true, double dismissThreshold = 140.0, LiquidGlassSettings? settings, GlassQuality? quality}) → Widget

Available on Widget, provided by the GlassFullScreenCoverExtension extension

Presents a full-viewport modal cover whenever isPresented is true.

Available on Widget, provided by the GlassNavigationTitleExtension extension

Annotates this widget with a navigation title that drives enclosing or descendant GlassAppBar / GlassAppBar.pinned bars (when their explicit title is null) as well as header accessibility semantics.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

show(BuildContext context, {required String message, Widget? icon, GlassToastType type = GlassToastType.success, GlassToastPosition position = GlassToastPosition.bottom, Duration duration = const Duration(seconds: 3), GlassToastAction? action, bool dismissible = true, LiquidGlassSettings? settings, GlassQuality? quality}) → VoidCallback
Shows a toast notification.