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
146 stars 90 forks source link

Add isAppearing and isHiding methods #16

Closed mkobuolys closed 3 years ago

mkobuolys commented 3 years ago

In our app, we have a case when we need to show the Flushbar on app state change. Currently, we are executing the logic like this:

if (state.isOff && !customFlushbar.isShowing()) {
    customFlushbar.show(context);
} else if (state.isOn && customFlushbar.isShowing()) {
    customFlushbar.dismiss(context);
}

However, there are cases when the state could change while the app is running in the background, then we receive multiple state change events at the same time on the app resume. As a result, the first condition returns true until the Flushbar animation ends which means that the customFlushbar.show(context); could be triggered multiple times, multiple Flushbars appear on top of each other.

To resolve this, I would like to expose the isAppearing() and isHiding() methods so we could check both states - whether the Flushbar is showing or the showing animation is ongoing.

cmdrootaccess commented 3 years ago

thank you. already added to branch