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: truefor screen reader announcements - Semantic labels for action buttons
- High contrast mode support via theme
- Respects reduce motion preferences for animations
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- GlassToast
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
-
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.