Skip to main content

just_sonner 0.8.0 copy "just_sonner: ^0.8.0" to clipboard
just_sonner: ^0.8.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.8.0 #

  • The deck can be warmed up so the first open after launch does not drop a frame (#168). toast.warmUp() fans out a deck of its own once, with one stand-in toast built from the controller's config — your builder or the default card, and the deckBackdrop when there is one — under the app's screen, and takes it away, so the first real open is not also the first time it is drawn. It works with SonnerHost; attached with attach, it does nothing. Call it while the app's screen is opaque. The stand-in is not one of your toasts and nothing you read from the controller changes. Nothing runs unless you call it.

0.7.0 #

  • An app can set how long each of the deck's motions takes (#162). SonnerConfig(motionDurations: MotionDurations(...)) takes one Duration for each of six motions: enter (400 ms), exit (200 ms), expand (400 ms), glide (400 ms), springBack (400 ms) and hide (300 ms). The defaults are the timings the deck already had, so nothing changes on upgrade. Each duration also times what moves with that motion: enter moves the toasts behind and fades the empty card, exit covers a swipe out and the gap closing, and expand fades the toasts beyond the window and eases the scroll back to the edge. Zero puts a motion at its end in one frame; a negative duration fails an assert. A motion already running keeps the duration it started with. Curves are unchanged.
  • The dismiss-all control can show with one toast (#163). DeckDismissAll(minCount: 1) shows it, its look or your builder, as soon as one toast the user may dismiss is up, so the deck's far end keeps the same shape as the hide control, which already shows with one. minCount is the fewest toasts that show it. It defaults to 2, as before, and must be at least
    1. Loading toasts and dismissible: false ones still do not count.
  • A header reads one toast as "1 notification" (#163). With no countLabel, the dismiss-all and hide headers used to read "1 notifications" for a single toast. A countLabel you give is unchanged.

0.6.0 #

  • The README's mode-1 example attaches after runApp. It called toast.attach before runApp, which throws "Binding has not yet been initialized" in debug, since attach reads the navigator key; the spec already said after runApp.
  • Attaching another navigator moves the toasts on screen at once (#152). attach with a different key, or attach after detach, took the toasts out of the old overlay and drew nothing in the new one until the next show, and raise() could not bring them back. With a toast alive or the zone open, attach now puts them into the new navigator's overlay right away, at the end of the frame when called during a build. With nothing to draw, or no navigator built under the key, it inserts nothing, as before.
  • A request finishing after its screen closed no longer reports an error (#155). A promise whose future settled after the controller was disposed reported a FlutterError in debug, which failed a widget test that closed a screen mid-request, and in release added a toast to the disposed controller. Its success or error state is now dropped: no toast, no report, and the future's own result or error still reaches the caller.
  • dismiss and dismissAll on a disposed controller assert before they change anything (#155). They removed the toast first and then threw, and an id not on screen passed silently. They now assert at once, as show and update do. In release they still act.
  • A builder's content can change in place on a see-through card (#157). On an update or a replace the new content fades in over the old, which stayed opaque underneath, so a builder whose card is see-through showed the old content through the whole fade and lost it in one frame. SonnerConfig.contentChange takes a ContentChange: cardOpacity set to the card's own opacity fades the old out so the two layers read as one card, 0 being a plain cross-fade; duration sets the fade's length, zero swapping in one frame; keep: true keeps the builder's widget, and its state, across every update and replace with no fade, so the card animates what changes itself. The defaults are the fade as before, and the default look keeps its own fade. ContentChange is exported.
  • The content an update or a replace fades out no longer takes the focus (#157). A button in it could be reached with Tab for the length of the fade.
  • toast.isAlive(id) says whether a given toast is still up (#150). It is true from show until the toast is dismissed or runs out, and stays true across a replace. An app adding to a toast it shows at its own id can now tell whether that toast has gone, by any way it can leave, and start afresh. It has no side effect. It does not say when a toast left or why, and there is still no callback for that.
  • toast.holdTimers() lets an app pause the timers (#149). It returns a TimerHold, and the timers stay paused until release() is called on it. On Windows and Linux a window covered by another reports inactive, which does not pause, so toasts ran out while the user was in another window. An app can now take a hold on AppLifecycleListener.onInactive and release it on onResume, or on any other signal it has. Each call is a hold of its own, and releasing one twice does nothing. TimerHold is exported. By default inactive still does not pause.
  • toast.raise() puts attached toasts back on top (#148). An entry another package inserted into the root overlay after the toasts covered them until the next toast, and zone.open() on an open zone did not lift them. raise() moves them back over it, keeping their state and animations. It does nothing before a toast is shown or the zone opened, after detach, and with SonnerHost.
  • Toasts can come in from the side (#141). SonnerConfig.enterMotion takes a ToastEnterMotion: edge, the slide from the top or bottom edge as before and the default, or left or right, which bring every toast in one toast's width from that side and take it out the same way. The side does not follow position. A toast already leaving when you assign another motion keeps leaving the way it was going, and a swiped toast still leaves the way it was swiped. ToastEnterMotion is exported.
  • Breaking: the deck can hide to the side (#141). DeckHideMotionLook gains slideLeft and slideRight, which carry the deck past that side of the window, fading, and bring it back the same way. DeckHideMotion() still slides past the edge. An exhaustive switch over DeckHideMotionLook in your code needs the two new cases.
  • A banner on a zone hidden empty slides in from the right distance (#143). A zone hidden before its deck was laid out or while it was empty, or a host built on a hidden zone, brought the next toast's banner in from the wrong distance under every slide: from across the window, or from just past its edge. The way back is now measured from the deck as it comes back, so a deck hidden open, which folds up as it goes, also comes back from its folded size. A motion builder's reach is unchanged.
  • The backdrop's blur fades in rather than growing (#142). With deckBackdrop set, opening the zone or fanning the deck out drew the blur at a sigma that grew from 0 to blur, and the first opens after launch dropped frames while the engine met each new sigma. The blur is now drawn at blur throughout, so an open no longer walks through every sigma, and fades in and out by its opacity; the dim is unchanged. DeckBackdrop is unchanged.

0.5.1 #

  • toast.count says how many toasts are alive (#122), those beyond visibleToasts and those that are not dismissible included. The controller's listeners are its change signal. An app can light a dot on its own button while a hidden zone has toasts, and bring the zone back once it is empty. With a banner up, the zone reads as hidden with toasts in the count.
  • A toast that leaves a hidden deck is gone at once (#123). It kept a 200 ms exit nobody could see, and if reveal(), open() or a new toast's banner brought the deck back during it, the toast showed again for about 100 ms after it had gone. A toast leaving a deck that is still on screen, a banner included, exits as before. A builder's ToastView.animation does not run down for a toast with no exit, and ToastView.dismiss's future completes as it is removed.
  • A deck brought back while it hides comes back (#124). With the pointer holding the deck, a listener that called zone.reveal(), zone.open() or showed a toast in the notification zone.hide() sends left the deck out of sight and out of reach, with the zone reading as shown or open, or a banner up. The deck now ends where the zone's state says.
  • A toast leaving beyond visibleToasts is gone at once (#126). It kept a 200 ms exit nobody could see, and if zone.open() or the pointer fanned the deck out during it, the toast showed for up to about 180 ms after it had gone. A toast crossing the edge of the window as it leaves, or leaving a deck that is fanned out, exits as before. As for a hidden deck, ToastView.animation does not run down for a toast with no exit, and ToastView.dismiss's future completes as it is removed.
  • A press does not hold a hidden deck (#128). A press that hid the deck from a listener, or that a host carried to a hidden controller, left zone.held true on a deck nothing drew, and a swipe from it dismissed a toast out of sight. It is now let go of, as hiding lets go of any other press, and no swipe starts from it. A banner takes a press and a swipe as before.
  • The dismiss-all control reads each toast as it reaches it (#129). A listener that made a toast not dismissible during it, or dismissed one and showed another at its id, lost that toast too. Now it stays. A toast replaced at its id during the press still goes if it is dismissible.
  • Hiding the deck cancels a click under way (#132). A press on a toast's close button or action that the deck hid under completed on release, dismissing a toast out of sight or running the action. The pointer is now cancelled as the deck hides. The cancel reaches everything that pointer was routed through, a tap detector wrapped around SonnerHost included, and hover on the app's widgets catches up at the next mouse move after the release.
  • A deck on its way back takes the pointer only where it is drawn (#133). For the 300 ms after zone.reveal(), or while a banner comes up, a click at the deck's resting place was held by the deck with nothing drawn there and never reached the app. It now reaches the app unless the deck is drawn under it.
  • A toast entering takes the pointer only where it is drawn (#137). For the 400 ms of its enter, a click at the place it was headed went to the deck with nothing drawn there. It now reaches the app until the toast has arrived, unless the pointer already holds the deck.

0.5.0 #

  • The deck glides under the mouse wheel (#107). A notch turned over a deck whose toasts do not fit moved it about 60 px in one frame; it now glides there on a spring that settles in 400 ms, and notches turned during a glide add to it. A toast arriving or leaving under a glide keeps the toasts you are reading in place. The same goes for a wheel over the dismiss-all and hide controls. A trackpad pan and a drag of the scrollbar's thumb move the deck as before.
  • Set how the deck glides (#110). SonnerConfig.wheelMotion takes a WheelMotion: WheelMotion.spring() by default, or another spring, a curve, a lerp, or WheelMotion.spring(duration: Duration.zero) to jump as in 0.4.2. A motion assigned while toasts are on screen applies from the next wheel turn. Two configs with equal motions are equal, even when the motions are built from runtime values (#118), so a config rebuilt every build with the same motion does not read as a change.
  • WheelMotion is exported from package:just_sonner/just_sonner.dart, so you set it without adding flutter_smooth_wheel_scroll yourself. It is that package's type: a breaking change to it there would be one here.
  • just_sonner now depends on flutter_smooth_wheel_scroll ^0.1.5, its first dependency beyond Flutter. Nothing to set up, and if your app installs its SmoothWheelBinding with a wheel scale, the deck follows that scale too.

0.4.2 #

  • The deck takes the pointer only where it is drawn (#104). While the pointer held a deck that could scroll, the deck kept the pointer in the band offset keeps clear at its edge and a margin past the cap, where nothing of it was drawn: a click there did not reach your app, and a pointer moved there kept the deck fanned out with its timers stopped. Both bands are now your app's, before and after a scroll.
  • A deck with no cap is cut at the far edge's offset (#104). With deckCap: () => null, a deck taller than the window was drawn into the band offset keeps clear on the far side, as 0.4.0 fixed at the near end (#86). It is now cut there, hard.

0.4.1 #

  • The backdrop stays out of the offset band before the deck is scrolled too (#101). With deckBackdrop set and the pointer resting on a deck that can scroll, the backdrop was drawn from the window's edge rather than from offset, over the band an app keeps clear for its own title bar, until a scroll cut it there. It is now cut at the offset edge whether the deck has scrolled or not, and DeckBackdrop.padding gives way to it there. Clicks are unchanged.
  • The example app opens on a showcase (#29): every argument of show and every part of SonnerConfig on a control, grouped on one page, beside buttons that show toasts with them. The harness each behaviour was verified in is on a page of its own, behind the app bar.

0.4.0 #

  • Breaking: a toast with no timer is shown with duration: null, not Duration.zero (#97). A toast shown with a duration is a transient toast and goes when it runs out; one shown with duration: null stays until the user or your app dismisses it; one shown without a duration takes config.duration as before. Duration.zero now asserts in debug, on show, update and SonnerConfig, where it used to mean "no timer": write duration: null instead. config.duration is a Duration?, set to null with copyWith(duration: () => null), which makes every toast shown without a duration stay. update(id, duration: null) takes a toast's timer away, and ToastContent(duration: null) makes a promise result stay. A function that passes a duration on to show now needs a default: with a plain Duration? duration, every call that leaves it out passes null and shows a toast with no timer. Give it Duration? duration = SonnerConfig.configDuration. A promise's loading content takes no duration at all, and ToastContent(duration: null) there now asserts as any other duration does.

  • Breaking: the zone replaces stowing (#97). toast.zone is the layer the deck lives in, your app's to open and close, and it exists with no toast up. Its state is shown, open or hidden:

    • zone.open() fans every toast out with no pointer, the ones beyond visibleToasts included, with the controls past the far end, and pauses nothing. With no toast it draws a card reading "No notifications" (config.zoneEmpty, null for none, or a builder of your own). The last toast leaving does not close it. zone.close() returns to the state open() was called from, so a zone opened from hidden hides again — a title-bar notification button needs no other code.
    • zone.hide() takes the deck out of sight with its toasts kept and counting down, as stow() did — but a new toast no longer brings the deck back: it shows the deck as a banner, the older toasts in it, until it has gone and the pointer has left, and the zone stays hidden. An empty zone stays hidden too. zone.reveal() brings it back.
    • zone.held says whether the pointer holds the deck, and the controller notifies when it changes, so your app decides what closes the zone.

    Removed: stow(), unstow() and stowed, and the edge handle — stowHandle, DeckStowHandle, DeckStowHandleView and DeckStowHandleBuilder; the entrance to a hidden zone is your app's own control. Renamed: stowControl → hideControl and stowMotion → hideMotion, with DeckStowControl, DeckStowLook, DeckStowView, DeckStowBuilder, DeckStowMotion, DeckStowMotionLook, DeckStowMotionView and DeckStowMotionBuilder → DeckHide…; a view's stow is hide, and a motion view's stowed is hidden. The Hide control now also shows on an open zone with no toast, and on a banner it takes the banner down. New: SonnerZone, ZoneState, ZoneEmpty, ZoneEmptyView and ZoneEmptyBuilder, and SonnerConfig.configDuration from the entry above.

  • Breaking: a drag a toast will not leave on moves it a little on either axis (#87). A toast on a centered deck used not to move at all when dragged sideways, since neither left nor right is a way out there, while a drag down on the same toast moved it a little and sprang back. Every drag the toast will not leave on is now damped that way, whichever axis it takes. swipeDirections: {} changes meaning with it: it used to take the swipe away, and now lets no swipe dismiss while a drag still moves the toast and springs it back. To take the drag away altogether, make the toast not dismissible.

  • A scrolled deck no longer draws over the offset band (#86). The deck is now cut at its near end as well as its far one. Scrolling a deck that overflows used to push toasts past the edge's own offset and go on painting them there — over the band an app keeps clear for its own title bar, and off the layer. The near end sits at that offset, fades over DeckCap.fade inward from it, and cuts hard where there is no fade; it does not need a deckCap at all, so a deck taller than the layer is cut there too. An exiting toast and the backdrop are cut with it. Clicks are unchanged: the near cut is paint only.

0.3.1 #

  • The fanned-out deck can blur what is behind it (#78). config.deckBackdrop is null by default and draws nothing, so nothing changes until you ask for it. With a DeckBackdrop the deck softens what is behind it as it fans out under the pointer, and fades it back as it collapses: blur is the filter's sigma, dim and color a cover over it (color null follows the theme's colorScheme.scrim), padding how far past the deck it reaches, and radius its corners. A click in that padding still reaches your app — what it draws over claims no pointer the deck did not already claim. It blurs what your app painted, not the desktop behind your window.

0.3.0 #

  • Breaking: offset is an EdgeInsets (#74). Each screen edge takes its own distance, so a deck can clear a title bar at the top and still sit close to the right edge. Write offset: EdgeInsets.all(24) where you wrote offset: 24. The edges are physical. A centered position ignores left and right. The edge the position names holds the deck off it; the opposite one is where the expanded deck stops.
  • Nothing is drawn past the deck's cap while it stows (#75). With many toasts and a cap that fades (the default), pressing Hide drew the oldest toasts past the cap for the first half of a slide or shrink stow. The fading cut now keeps them out, as a hard cut already did.

0.2.0 #

  • A taller toast behind a shorter front keeps its whole card (#72). It is laid out at the front's height rather than cut to it, so its bottom edge and corners are drawn. Before, only the two side edges of its card peeked out past the front.
  • Breaking for a builder: a builder is now laid out below its own height whenever its toast is behind a shorter front. Wrap what is written on the card in the new ToastFit, inside the card, or build the look with the new toastCardBuilder, which takes the card and its content apart and also fades the content by covered. A builder that does neither reports an overflow in debug, which fails a widget test showing toasts of mixed heights. In release the deck clips it, so nothing shows past the card.

0.1.0 #

First release. Desktop only: Windows, macOS and Linux.

  • Toasts from anywhere. toast.show needs no BuildContext and returns a ToastId. update changes a toast field by field; show at the id of a toast on screen replaces its content whole. Either way the toast keeps its place and counts down again. dismiss and dismissAll take 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. SonnerHost wraps the app from MaterialApp.builder.
  • The deck. Toasts stack into a deck that draws visibleToasts of 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 swipeDirections gives.
  • 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. dismissible governs 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, and dismiss.
  • 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 or unstow() 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.
1
likes
0
points
624
downloads

Publisher

verified publisherkihyun1998.com

Weekly Downloads

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.

Repository (GitHub)
View/report issues

Topics

#toast #notification #snackbar #overlay #desktop

License

unknown (license)

Dependencies

flutter, flutter_smooth_wheel_scroll

More

Packages that depend on just_sonner