Skip to content

Toaster

Hosts toast notifications. Place one high in the app (wrapping your content); it floats toasts in a screen corner above everything — including modals — via an Overlay entry, stacking them and auto-dismissing each after a delay unless it is persistent.

Import: package:fleury/fleury.dart, or package:fleury/fleury_core.dart in browser code.

// Wrap your app once:
Toaster(child: app)
// …then from anywhere below it:
Toaster.show(context, 'Saved', severity: ToastSeverity.success);

To show a toast from anywhere below it, call Toaster.show with a BuildContext and the message. It returns a ToastHandle that can dismiss that toast early.

ParameterTypeDefaultDescription
child:WidgetrequiredApplication subtree over which toast overlays are presented.
alignment:AlignmentAlignment.bottomRightWhich corner toasts stack in.
duration:Durationconst Duration(seconds: 5)How long each toast stays before auto-dismissing.
maxToasts:int?—Maximum retained toasts. Null preserves unrestricted stacking. More
  • maxToasts: Adding a distinct toast while full evicts the oldest, even if persistent. There is no pending queue. Replacing an ID retains its position and does not consume another slot. Reducing the limit also evicts oldest toasts.

Toaster is defined in packages/fleury/lib/src/catalog/toaster.dart.

Category: Navigation & overlays · All widgets