marcglasberg / back_button_interceptor

Flutter Package: May be used to intercept the Android back-button, as an alternative to `WillPopScope`.
BSD 2-Clause "Simplified" License
105 stars 21 forks source link

Snackbar is closed instead of going back #5

Closed bajajsahil closed 3 years ago

bajajsahil commented 3 years ago

Hi @marcglasberg ,

Thanks for the great package.

I am facing one issue though. I am implementing double tap back button functionality in which first I am showing snackbar and on second tap I need to close the APP( or route to the previous screen if any). But, on the second tap when I am return false, it is just closing the snackbar.

Can you please help with this?

Thanks.

marcglasberg commented 3 years ago

It seems to me the second tap is not being intercepted by the back_button_interceptor. So the Snackbar uses WillPopScope to do its thing, which is closing itself.

I see 2 solutions:

1) Create a custom MySnackbar widget that doesn't intercept the back-button, and use it instead of the regular Snackbar that does.

2) Use the back-button interceptor to intercept the second tap as well, and then force-close the app yourself.

Hope it helps.

bajajsahil commented 3 years ago

Thanks @marcglasberg for the response. I will check the way you suggested.