cmdrootaccess / another-flushbar

A flexible widget for user notification. Customize your text, button, duration, animations and much more. For Android devs, it is made to replace Snackbars and Toasts.
https://pub.dev/packages/another_flushbar
MIT License
145 stars 88 forks source link

Flushbar dismisses when I use Navigator.pop() #103

Closed adminant closed 1 year ago

adminant commented 1 year ago

I use flushbar in my appbar, so it appears throughout all my app and works as expected except one thing - when somewhere in my app I use modal windows which are dismissed by Navigator.pop() the flushbar disappears first instead of that modal window. How can I have flushbar to be always on screen and not disappear with Navigator.pop() calls?

TheHypnoo commented 1 year ago

@adminant Hi

Flushbar is a Future, in my case I used Navigator.pop(context), it caused errors. I recommend you to do an await

cmkramer commented 1 year ago

This is actually a serious issue. A toast like notification should never rely on or affect the router stack. Since there's no way around it, I actually decided to remove Flushbar altogether.

AliEasy commented 1 year ago

@cmkramer And what is your alternative?!

adminant commented 1 year ago

As for me, I ended up not using Flushbar at all and use my own overlay-based widget, and that required some work to do. It's a pity such a useful plugin like Flushbar has such a confusing bug

silverhairs commented 1 year ago

This is actually a serious issue. A toast like notification should never rely on or affect the router stack. Since there's no way around it, I actually decided to remove Flushbar altogether.

@cmkramer is there any alternative that you used?

I think the issue is that this package is a continuation of a the discontinued flushbar package so it uses a somehow similar API. Though I agree that it's worth exploring different approaches

cmdrootaccess commented 1 year ago

as far as i know Navigator.pop() is a future. if flushbar is being dismissed by it, you can make your own checks so that its not dismissed.

Also its best to understand what Navigator.pop() does beyond the basic understanding .

this library cant support every developers custom needs. if you feel like this is a bug in the library implementation please add your code snippet so others can review and advise

adminant commented 1 year ago

as far as i know Navigator.pop() is a future. if flushbar is being dismissed by it, you can make your own checks so that its not dismissed.

Could you explain, how this check could be made? And where it should be located?

cmkramer commented 1 year ago

As per request above @AliEasy and @silverhairs . I switched to overlay_support. This package creates a global overlay that can easily be styled just like Flushbar. It actually provides an easy way to implement other styles of modal user feedback as well. I've been using it since I placed my previous comment and I'm quite happy with the switch.

franka107 commented 1 year ago

you can show flushbar after a navigation action:

SchedulerBinding.instance.addPostFrameCallback((_) {
              Flushbar(
                      flushbarStyle: FlushbarStyle.GROUNDED,
                      flushbarPosition: FlushbarPosition.TOP,
                      messageColor: Theme.of(context).colorScheme.onPrimary,
                      backgroundColor: Theme.of(context).colorScheme.primary,
                      duration: const Duration(seconds: 3),
                      message: i18n.loginSuccessful(userFullName))
                  .show(context);
            });