<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rtfmko on Medium]]></title>
        <description><![CDATA[Stories by Rtfmko on Medium]]></description>
        <link>https://medium.com/@rtfmko?source=rss-bdb2bc072e3d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MJ1qkvlBTsgDexN0</url>
            <title>Stories by Rtfmko on Medium</title>
            <link>https://medium.com/@rtfmko?source=rss-bdb2bc072e3d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 07:49:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rtfmko/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Do Flutter toasts overlap? Queue, duplicates and analytics in one package]]></title>
            <link>https://medium.com/@rtfmko/do-flutter-toasts-overlap-queue-duplicates-and-analytics-in-one-package-ea8d4b006cf7?source=rss-bdb2bc072e3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea8d4b006cf7</guid>
            <category><![CDATA[fluent-bar]]></category>
            <category><![CDATA[toast]]></category>
            <category><![CDATA[notifications]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Rtfmko]]></dc:creator>
            <pubDate>Mon, 26 Oct 2026 17:22:47 GMT</pubDate>
            <atom:updated>2026-10-26T17:26:40.644Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3hzoDD63TJVZe_bGPIQ-dQ.png" /></figure><p>A user logs in, and a “Welcome back!” bar appears. A second later, background sync shows “Data updated”. A second after that, the server responds: “Couldn’t refresh your balance”. All three bars appeared in the same place. We expected the user to see three messages, but the first bar disappeared after a second, and the second one was covered.</p><p>That’s what happened in our app after we added bars for login, logout, data sync and server responses. Each scenario fired its own bar, and nobody tracked what was already on screen. The bars piled on top of each other.</p><p>The second problem: the bar had to be called from BLoC and from the layer that talks to the API. A standard SnackBar requires ScaffoldMessenger and BuildContext, so we would have had to pass a context into places where there are no widgets.</p><p>The third problem: we needed analytics. We wanted to know whether a bar was shown, whether the user tapped its button, how long it stayed on screen, and whether it was swiped away. A standard SnackBar does part of this: it reports that it was shown and returns the reason it was closed. But you have to collect that data at every call site, and the time on screen and the link to the queue are left to the developer.</p><p>That’s how fluent_bar came about: a package for showing bars in Flutter. Below: what it does, how to use it, and why it’s built this way.</p><h3>How it differs from other packages</h3><p>There are several popular notification and toast packages for Flutter, and most of them solve one job: showing a message. A large app usually needs more:</p><ul><li>not stacking messages on top of each other;</li><li>updating a message that’s already on screen;</li><li>tracking when a message is shown and how the user reacts;</li><li>showing progress without passing BuildContext into every call.</li></ul><p><strong>fluttertoast</strong> queues messages, but only in the BuildContext mode. Without it, you get simple toasts with limited features.</p><p><strong>toastification</strong> queues, provides callbacks and a progress strip, but the docs don’t describe updating a toast by id.</p><p><strong>flutter_easyloading</strong> shows progress from 0 to 1 and errors, and its status callbacks let you build your own analytics. But it’s a single loading indicator, not a message queue.</p><p><strong>bot_toast</strong> lets you close each toast separately, but the docs describe neither a queue nor updating by id.</p><p><strong>fluent_bar</strong> brings these tasks together in one mechanism:</p><ul><li>a queue with priorities and two independent regions (top and bottom);</li><li>updating a bar by id, with four policies for duplicates;</li><li>progress with cancel and retry;</li><li>fifteen analytics events with metrics for each bar;</li><li>isolation of errors thrown by user code;</li><li>showing bars without BuildContext after a one-time overlay setup.</li></ul><p>Quick comparison (data from each package’s pub.dev docs as of 22.10.2026; “not described” means the docs don’t mention it):</p><ul><li><strong>fluent_bar</strong></li><li>Queue: yes, with priorities and two regions.</li><li>Update by id: yes, with four policies.</li><li>Analytics: yes, 15 events.</li><li>Progress: yes, with cancel and retry.</li><li>Without BuildContext: yes, after overlay setup.</li></ul><p><strong>fluttertoast</strong></p><ul><li>Queue: only with BuildContext.</li><li>Update by id: not described.</li><li>Analytics: not described.</li><li>Progress: not described.</li><li>Without BuildContext: simple toasts with limited features, no queue.</li></ul><p><strong>toastification</strong></p><ul><li>Queue: yes.</li><li>Update by id: not described; there is search and close by id.</li><li>Analytics: not described.</li><li>Progress: a progress strip.</li><li>Without BuildContext: yes, with a wrapper.</li></ul><p><strong>flutter_easyloading</strong></p><ul><li>Queue: not described.</li><li>Update by id: show updates the indicator.</li><li>Analytics: status callbacks.</li><li>Progress: from 0 to 1.</li><li>Without BuildContext: yes, after Host.</li></ul><p><strong>bot_toast</strong></p><ul><li>Queue: not described.</li><li>Update by id: not described.</li><li>Analytics: not described.</li><li>Progress: loading without progress.</li><li>Without BuildContext: yes, after BotToastInit.</li></ul><h3>What it does</h3><p>A bar is a card with text, an icon, progress, a button and a timer strip. It can appear at the top, bottom, center or side of the screen, and top and bottom bars behave as two separate queues. You can safely create your own themes, types and queues, and build your own widget inside a bar, while positioning, timers and the queue stay with the package. If user code throws, the package doesn’t crash: all errors go to a single handler.</p><h3>The shortest call</h3><pre>FluentBar.showSuccess(&#39;Profile saved&#39;);</pre><p>The bar appears immediately if the overlay is ready. If the app hasn’t started yet, see the example below.</p><p>For a single line, that’s enough. If you need a button, progress or a custom duration, use a chain:</p><pre>FluentBar.info(&#39;Uploading 12 photos&#39;)<br>    .withId(&#39;upload&#39;)<br>    .withLinearProgress(value: 0, showText: true)<br>    .atBottom()<br>    .show();</pre><p>withId is the bar’s key. Use it to find, update or close the bar from anywhere:</p><pre>FluentBar.find(&#39;upload&#39;)?.updateValue(0.42);<br>FluentBar.close(&#39;upload&#39;);</pre><h3>The queue: how it works</h3><p>The screen is split into two regions: top and bottom. Each has one queue and one bar on screen. Think of a checkout line in a shop: in each region, one customer is served at a time while the others wait. Top and bottom messages don’t block each other, because they have separate checkout lines.</p><p>A new bar joins the queue. If it’s more important, give it a priority: critical, high, normal or low. If it needs to show right away, mark it as forced, and it replaces the current bar:</p><pre>FluentBar.error(&#39;Session expired&#39;).forced().show();</pre><p>That order makes sense: an error asking the user to log in won’t have to wait behind an ad banner.</p><figure><img alt="Two queues: top and bottom" src="https://cdn-images-1.medium.com/max/1024/1*dSKNpDxOjVFu_QMJqTMFyg.png" /><figcaption><em>The top and bottom regions work as two independent queues. Filled chips are on screen, light chips are waiting.</em></figcaption></figure><figure><img alt="Forced bar replaces the current one" src="https://cdn-images-1.medium.com/max/540/1*tfHBi-MCT61x00syDnWLZQ.gif" /><figcaption><em>A normal bar waits in the queue, while a bar with </em><em>forced() replaces the one on screen.</em></figcaption></figure><h3>Duplicates and updates</h3><p>If a bar with the same id is already on screen, a new call doesn’t create a copy. It updates the existing bar in place:</p><pre>FluentBar.toast(&#39;Copied&#39;, id: &#39;copied&#39;).show();<br>FluentBar.toast(&#39;Copied&#39;, id: &#39;copied&#39;).show(); // updates the first bar</pre><p>By default, the bar is updated. For duplicates there are policies: update the content, update and reset the timer, ignore the new call, or allow a copy. A policy can be set on a bar or for the whole app. You can also provide your own duplicate comparator to override the default duplicate search.</p><figure><img alt="A toast updates in place" src="https://cdn-images-1.medium.com/max/540/1*qCG4METsyFiMcOEOpvEWOw.gif" /><figcaption><em>Two identical calls in a row produce one bar that updates in place.</em></figcaption></figure><h3>Progress, cancel, retry</h3><p>Uploads are a common case, and progress is where the package helps most. A bar shows progress, and you can update it:</p><pre>final FluentBarEntry? entry = FluentBar.info(&#39;Uploading 12 photos&#39;)<br>    .withId(&#39;upload&#39;)<br>    .withLinearProgress(value: 0, showText: true)<br>    .atBottom()<br>    .show();<br><br>// on each progress update:<br>entry?.updateValue(0.42);<br>// when everything is uploaded:<br>entry?.completeProgress(message: &#39;All photos uploaded&#39;, type: FluentBarType.success);</pre><h3>Progress and cancel</h3><p>You can link a “Cancel” button to a task. When the user taps “Cancel”, the bar stops the progress, and the button shows a loader. If the onCancel callback is async, the button keeps spinning until it finishes, and only then the bar shows canceledMessage.</p><pre>FluentBar.info(&#39;Downloading the map&#39;)<br>    .withId(&#39;map&#39;)<br>    .withLinearProgress(value: 0, showText: true)<br>    .withCancelButton(<br>      &#39;Cancel&#39;,<br>      onCancel: () async {<br>        task.cancel();<br>        await Future&lt;void&gt;.delayed(const Duration(milliseconds: 1200)); // the button spins until the callback completes<br>      },<br>      canceledMessage: &#39;Download canceled&#39;,<br>      canceledType: FluentBarType.warning,<br>    )<br>    .show();</pre><figure><img alt="Canceling a download" src="https://cdn-images-1.medium.com/max/540/1*xBGT2f7YwwJ_UpxU-h_xUw.gif" /><figcaption><em>The progress stops, the Cancel button spins while the callback runs, then the bar shows “Download canceled”.</em></figcaption></figure><h3>Progress and retry</h3><p>If the task fails, failProgress turns the bar into an error with a “Retry” button. The example below uses a warning instead. Tapping it calls onRetry. The retry happens in the same bar, because the id is the same.</p><pre>void download() {<br>  final entry = FluentBar.info&lt;void&gt;(&#39;Downloading the map&#39;)<br>      .withId(&#39;map&#39;)<br>      .withLinearProgress(value: 0, showText: true)<br>      .withCancelButton(&#39;Cancel&#39;, onCancel: () =&gt; task.cancel(), canceledMessage: &#39;Download canceled&#39;)<br>      .show();<br><br>  task.start(<br>    onProgress: (received, total) =&gt; entry?.updateBytes(received, total),<br>    onDone: () =&gt; entry?.completeProgress(message: &#39;Map downloaded&#39;, type: FluentBarType.success),<br>    onError: () =&gt; entry?.failProgress(<br>      message: &#39;Download failed&#39;,<br>      type: FluentBarType.warning, // warning instead of the default error<br>      retryLabel: &#39;Retry&#39;,<br>      onRetry: download, // same id: the bar starts over in place<br>    ),<br>  );<br>}</pre><figure><img alt="Download, failure and retry" src="https://cdn-images-1.medium.com/max/540/1*S7nGd-CIJngaVRF-8pw1pw.gif" /><figcaption>In the GIF above, the download fails and Retry starts it again in the same bar.</figcaption></figure><h3>Success</h3><p>For a single async call, there’s FluentBar.future. It shows loading, then a success or error message, and returns the result to the calling code. If the future fails, the bar shows the text returned by the error callback. Without a callback, the loading text stays and only the type changes to error. The exception still propagates, so await throws as usual.</p><pre>try {<br>  final User user = await FluentBar.future&lt;User&gt;(<br>    api.saveProfile(),<br>    loading: &#39;Saving…&#39;,<br>    success: (user) =&gt; &#39;Profile ${user.name} saved&#39;,<br>    error: (_) =&gt; &quot;Couldn&#39;t save&quot;,<br>  );<br><br>// continue working with user<br>} catch (e) {<br>  // the bar has already shown &quot;Couldn&#39;t save&quot;; here you can only log it or roll back state<br>}</pre><figure><img alt="Loading, then success in one bar" src="https://cdn-images-1.medium.com/max/540/1*0fP_KrUK0JUvfuM4ftxFvg.gif" /><figcaption><em>The bar shows loading, then the success text.</em></figcaption></figure><p>Calling it from BLoC looks the same, and no context is needed:</p><pre>Future&lt;void&gt; save() async {<br>  final FluentBarEntry? entry = FluentBar.info(&#39;Saving…&#39;).withId(&#39;save&#39;).persistent().show();<br>  try {<br>    await repository.save();<br>    entry?.completeProgress(message: &#39;Saved&#39;, type: FluentBarType.success);<br>  } catch (_) {<br>    entry?.failProgress(message: &#39;Failed&#39;);<br>  }<br>}</pre><h3>Analytics</h3><p>One subscription receives events from all bars:</p><pre>FluentBar.addAnalyticsListener((payload) {<br>  analytics.log(payload.event.name, {&#39;id&#39;: payload.item.id, ...?payload.metrics?.toMap()});<br>});</pre><p>There are fifteen events: queued, shown, tapped, closed, updated, and so on. For a closed bar, there are metrics: how long it was on screen, why it closed (button, timer, swipe), whether the action button was tapped, and how long it waited in the queue.</p><p>This covers the analytics problem from the start: was the bar shown, and did the user tap it? Before this, we wrote separate code at every call site.</p><figure><img alt="Analytics screen" src="https://cdn-images-1.medium.com/max/1024/1*GTpfwjGI78HImvbWuGdZtA.png" /><figcaption><em>Event counters and the event stream for all bars. Tapping a row opens that bar’s card.</em></figcaption></figure><h3>Settings: from a single bar to the whole app</h3><p>Values can be set in three places, and the first one found applies, so you can tune settings per bar:</p><ul><li>on a specific bar;</li><li>on a bar type;</li><li>in the global configuration.</li></ul><pre>FluentBar.patchConfig((config) =&gt; config.copyWith(defaultDuration: const Duration(seconds: 5)));</pre><p>A type is a group of bars with shared settings, for example “promo” or “network error”:</p><pre>class PromoType extends FluentBarType {<br>  const PromoType();<br>  @override String get name =&gt; &#39;promo&#39;;<br>  @override Color? get backgroundColor =&gt; const Color(0xFFBE185D);<br>  @override FluentBarPosition? get position =&gt; FluentBarPosition.bottom;<br>}</pre><pre>FluentBar.showCustom(const PromoType(), &#39;20% off until Friday&#39;);</pre><p>You can override a type globally, without editing every call. This is handy for changing the look of all bars of one type at once.</p><h3>Setup: three ways</h3><p>The package needs an overlay. You can connect it in three ways:</p><ul><li>MaterialApp(builder: FluentBarScope.builder()), the simplest;</li><li>navigatorKey, if you’ve already created the navigator yourself;</li><li>FluentBarObserver.instance in navigatorObservers.</li></ul><p>Bars tied to a screen should close together with it. For this, there are tags and FluentBarOwner:</p><pre>class CheckoutScreen extends StatelessWidget {<br>  const CheckoutScreen({super.key});<br><br>@override<br>  Widget build(BuildContext context) =&gt; FluentBarOwner(<br>    tag: &#39;checkout&#39;,<br>    child: Scaffold(<br>      body: FilledButton(<br>        onPressed: () =&gt; FluentBar.error(&#39;Card declined&#39;).withTag(&#39;checkout&#39;).show(),<br>        child: const Text(&#39;Pay&#39;),<br>      ),<br>    ),<br>  );<br>}</pre><p>The tag is set manually. The bar doesn’t know which screen it was shown from, so you need to write .withTag(&#39;checkout&#39;) in the call. FluentBarOwner closes the bars with this tag when the screen leaves the tree.</p><p>Bars without a tag are not closed when the screen goes away, even if they were shown from it.</p><p>If the same screen is open twice, the bars close only after the last FluentBarOwner instance with this tag is gone.</p><h3>Timer and hold</h3><p>Touching and holding a bar pauses its timer: while your finger is on the bar, it won’t close. Once you lift your finger, the countdown continues. This gives you time to read a long message. There turned out to be more edge cases here than it seems, which is why there are many tests for this behavior.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*4-La9imFtMiUakrFRln4gQ.gif" /><figcaption><em>While a finger is on the bar, the timer is paused. When it’s released, the countdown continues.</em></figcaption></figure><p>If “reduce motion” is enabled in the system, bars appear without sliding, and effects don’t run.</p><h3>What was hard</h3><p><strong>Lifecycle.</strong> A bar goes through several states: queued, appearing, in place, closing, removed. The timer should start when the bar is already in place, not while it’s appearing. A bar closed manually during its animation must not get stuck. We described the transitions and checked them with tests, including the metrics for each transition.</p><figure><img alt="Bar card with its lifecycle" src="https://cdn-images-1.medium.com/max/1024/1*UZ3qAsweRDy43G0ZKCrUYg.png" /><figcaption><em>The bar card: lifecycle with timings, metrics and this bar’s events.</em></figcaption></figure><p><strong>Fast updates.</strong> Progress can arrive dozens of times per second. At first, the text flickered: the number disappeared because two animations overlapped and the bar updated too fast. We measured the visibility of each character on each frame and saw it drop almost to zero. The fix: while an animation is running, new values don’t start the next one. They wait in a queue of one, and the last value is shown at the end. So the number may lag behind the progress by about the length of the transition, but it doesn’t flicker.</p><p><strong>Errors in user code.</strong> A callback, builder or theme can throw an exception. The bar must not crash because of it. The error goes to a handler you register, and the default bar is shown instead.</p><pre>FluentBar.addErrorHandler((error, stackTrace) { // registers the handler<br>  if (error.severity.isWarning) {<br>    FirebaseCrashlytics.instance.log(&#39;fluent_bar warning: ${error.type.displayName}&#39;); // logs a warning<br>    return;<br>  }<br>  FirebaseCrashlytics.instance.recordError(error.error, stackTrace, reason: &#39;fluent_bar: ${error.type.displayName}&#39;); // the error is recorded<br>});</pre><pre>FluentBar.info(&#39;Saved&#39;).withContent((context, entry) {<br>  throw StateError(&#39;no profile data&#39;); // the default bar will be shown instead<br>}).show();</pre><p><strong>Call order.</strong> A bar can be shown before the app is ready. This is convenient from main(), but it needed separate logic: the bar waits in the queue and appears once the overlay is ready.</p><pre>void main() {<br>  FluentBar.showInfo(<br>    &#39;Long time no see! We missed you&#39;,<br>    duration: const Duration(seconds: 6),<br>  );<br>  runApp(const BestApp());<br>}<br><br>class BestApp extends StatelessWidget {<br>  const BestApp({super.key});<br>  @override<br>  Widget build(BuildContext context) =&gt; MaterialApp(<br>    builder: FluentBarScope.builder(),<br>    onGenerateRoute: Router.route,<br>    onGenerateInitialRoutes: Router.initialRoutes,<br>  );<br>}</pre><figure><img alt="Playground: bar settings and call code" src="https://cdn-images-1.medium.com/max/1024/1*0_NP-xnvhd9P_6oGDFLVBA.png" /><figcaption><em>Playground: bar settings and the generated call code.</em></figcaption></figure><h3>How we test it</h3><p>The key logic is covered by tests: the bar lifecycle, behavior when user code throws, the queue and its transitions, animations and settings. CI runs them on the latest stable Flutter and on the minimum declared version, 3.32.0. This way we check that the package works on both the minimum and the latest version.</p><p>The demo app has a screen for each feature: queue and duplicates, progress, themes and types, monitoring, analytics.</p><p>The best place to start is the Playground: you configure a bar (position, duration, progress, button), see the result, and get the call code right away.</p><h3>Other things in the package</h3><p><strong>Recipes.</strong> The README has ready-made solutions: “Saved”, “Cancel”, “Retry”, a banner for no network, a cookie-consent button.</p><p><strong>Integrations.</strong> doc/INTEGRATIONS.md has examples with BLoC, provider, riverpod, Firebase and others.</p><p><strong>Accessibility.</strong> Bars are announced to screen readers, and there are “quiet” and “hidden” modes.</p><h3>Try it</h3><p>Demo in the browser: <a href="https://rtfmko.github.io/fluent_bar/">Demo</a></p><p>Package: <a href="https://pub.dev/packages/fluent_bar">fluent_bar on pub.dev</a></p><p>Source code and README: <a href="https://github.com/rtfmko/fluent_bar">GitHub</a></p><p>The package has just reached version 1.0.0, and we’d love your feedback! If you find a bug or want a new feature, open an issue. We’ll try to add things based on what people ask for.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea8d4b006cf7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>