DesignToaster class

Hosts toasts over child: put it above the app's navigator (WidgetsApp.builder), then call DesignToaster.of and DesignToasterState.show from anywhere below.

At most maxVisible show at once, oldest first; the rest wait their turn in order. Each shown toast's time runs only while the stack is neither hovered nor holding focus. focusShortcut (F6) moves focus to the newest toast; Escape there dismisses it and focus goes back where it was.

DesignToaster(toastBuilder: (context, details) => Text(details.toast.message), child: const SizedBox())
Inheritance

Constructors

DesignToaster({Key? key, required Widget child, required DesignToastBuilder toastBuilder, DesignToastStackBuilder? stackBuilder, int maxVisible = 3, AlignmentGeometry alignment = AlignmentDirectional.bottomCenter, EdgeInsetsGeometry padding = const EdgeInsets.all(16), BoxConstraints constraints = const BoxConstraints(maxWidth: 560), bool pauseOnHover = true, bool pauseOnFocus = true, DismissDirection swipeDirection = DismissDirection.horizontal, ShortcutActivator? focusShortcut = const SingleActivator(LogicalKeyboardKey.f6), double dampingRatio = 1, double stiffness = 700, String? regionLabel, Duration tick = const Duration(milliseconds: 100)})
A toaster over child.
const

Properties

alignment → AlignmentGeometry
Where the stack sits.
final
child → Widget
The app the toasts float over.
final
constraints → BoxConstraints
The stack's size limits.
final
dampingRatio → double
The presence spring's damping ratio (ζ); critically damped under Reduce Motion (DesignMotionPolicy).
final
focusShortcut → ShortcutActivator?
The key that moves focus to the newest toast; null for none.
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxVisible → int
How many show at once; 1 is a snackbar's queue.
final
padding → EdgeInsetsGeometry
Space between the stack and the screen's edge (inside the safe area).
final
pauseOnFocus → bool
Whether focus in the stack pauses every shown toast's time.
final
pauseOnHover → bool
Whether a pointer over the stack pauses every shown toast's time.
final
regionLabel → String?
What a screen reader calls the stack while it holds a toast; an empty stack is silent, so no screen stops on it. Null: DesignLocalizations.toasterRegionLabel.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
stackBuilder → DesignToastStackBuilder?
Lays out the shown toasts; null stacks them in a column, oldest first.
final
stiffness → double
The presence spring's stiffness (k).
final
swipeDirection → DismissDirection
Which way a toast swipes away; DismissDirection.none turns it off.
final
tick → Duration
How finely a toast's time is counted.
final
toastBuilder → DesignToastBuilder
Paints one toast.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<DesignToaster>
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.
override
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

maybeOf(BuildContext context) → DesignToasterState?
The nearest toaster's state, or null.
of(BuildContext context) → DesignToasterState
The nearest toaster's state.