just_sonner 0.1.0
just_sonner: ^0.1.0 copied to clipboard
Stacking toasts for Flutter desktop in the spirit of sonner: a deck that fans out on hover, toasts updated in place, promise toasts, no BuildContext.
0.1.0 #
First release. Desktop only: Windows, macOS and Linux.
- Toasts from anywhere.
toast.showneeds noBuildContextand returns aToastId.updatechanges a toast field by field;showat the id of a toast on screen replaces its content whole. Either way the toast keeps its place and counts down again.dismissanddismissAlltake toasts away. promise. One toast for the whole of a future: loading, then its result or its error. The future's own value or error goes back to the caller unchanged.- Two mount modes.
toast.attach(navigatorKey)draws the toasts in the root navigator's overlay, above dialogs and pages.SonnerHostwraps the app fromMaterialApp.builder. - The deck. Toasts stack into a deck that draws
visibleToastsof them and fans out, every toast drawn, while the pointer is over it. Six positions; width, gap and offset. - Timers pause while the pointer is over the deck, while a toast is dragged, and while the app is hidden. Toasts beyond the deck's window count down like the rest.
- Swipe to dismiss, in the directions the position names or the ones
swipeDirectionsgives. - A default look that follows the theme, light and dark, with a leading slot, an action slot,
a close button, and a spinner while a toast loads.
dismissiblegoverns every way a user dismisses a toast. - A builder that replaces the whole look, per toast or for every toast, handed a
ToastView: the toast's state, its animation, how much the deck covers it, its time left, anddismiss. - Time left, drawn by the default look as a border, a bar, or a ring, each with settings of
its own (
config.timeLeft). - A cap on the expanded deck (
config.deckCap, 400 px by default), past which the toasts scroll, with a draggable scrollbar beside them (config.scrollbar). - Dismiss all from the deck (
config.dismissAll): a pill or a header, or the app's own control through a builder. - Stow the deck:
stow()puts it out of sight, keeping its toasts, until the next new toast orunstow()brings it back. A control on the deck (config.stowControl), a motion (config.stowMotion) and a handle left at the edge (config.stowHandle), each with built-in looks and a builder. - Changing the config with toasts on screen, which the deck follows in place.