Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] - How to handle Android hardware back button when Flushbar is open #43

Closed
angel1st opened this issue Apr 12, 2019 · 4 comments
Labels
enhancement New feature or request priority This issue is a priority and is currently being worked on

Comments

@angel1st
Copy link

angel1st commented Apr 12, 2019

Hi there. First of all,
I would like to say - the Flushbar is an amazing package - it can handle most of the cases with ease.

I have however one particular case, where I cannot see how to properly configure / use it. Here is it:

I would like to show a Flushbar when the user is on the app Home page and taps Android hardware back button. The short message pops and says "Tap once more to exit" and stays with certain duration e.g. 10 seconds. If within the duration the user taps the back button once more, the app will close, otherwise the message closes and the process can start over. I am able to show the Flushbar with the message, however, while it is open, if the user taps back button one more time, the back button event goes to the Flushbar rather than to the Home page. The side effect is that this tap event closes the Flushbar message rather than be sent to the Home page, where I can handle it.
If I use a standard flutter SnackBar everything works as I expected - even though the snackbar is visible the back button tap event is sent to the Home page.

Please note, the above behavior is true even though isDismissible = false.

Any idea how I can overcome the above side effect and properly get Android back button event in my page, when Flushbar is open?

@AndreHaueisen
Copy link
Owner

Hi @angel1st
So, right now I'm overwhelmed with projects. I'm afraid a new Flushbar version is gonna have to wait a bit.
On top of my mind I have two possible solutions:
1 - Put a close button inside Flushbar and change the text to "Are you sure you want to leave?". If the user clicks it, you pop every route leaving the app.
2 - Listen to Flushbar's dismissal and to the system back button (to be honest don't know if that is possible in Flutter). If those two are true, close the app.

Thanks for the feedback. Let me know how it goes.

@angel1st
Copy link
Author

Thanks for the feedback, @AndreHaueisen. TBH - neither from above would match to the expected user experience I am striving to achieve. That said, I would stick to the good old SnackBar for this particular case. Thanks again for your feedback and I look forward to using the next Flushbar version!
I would leave to you weather or not to close the issue, IMO - I consider the above Flushbar behavior as a bug which needs to be fixed.

@AndreHaueisen
Copy link
Owner

See issue

@AndreHaueisen AndreHaueisen added enhancement New feature or request priority This issue is a priority and is currently being worked on labels Jun 1, 2019
@AndreHaueisen
Copy link
Owner

After a lot of research, I decided to accept this as a tradeoff.
Routes in Flutter are done in LIFO style. There is no way of poping the bottom route without popping the top one first.
Since you can know exactly when the notification is being popped, I don't see it as a big issue.
Yes, this is different behavior than the official one, but we gain in code simplicity and avoid a lot of boilerplate code, which is what I was trying to solve when I first created the package.
To conclude, Android back button will continue dismissing the notification until there is a significant change on how Flutter deals with routes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority This issue is a priority and is currently being worked on
Projects
None yet
Development

No branches or pull requests

2 participants