Closed anandrajak2 closed 1 year ago
I have the same problem. When I use modal_bottom_sheet showCupertinoModalBottomSheet
shows a bottomSheet, then click the back button on the Android device, it clears the bottomSheet and pops back to previous screen (or exit the app if it is the root screen)
If I use Navigator.of(context).push(Route)
to navigate to another screen, the back button works fine (pops out the bottomSheet only, do not pops to previous screen together). But If I use QR.to(screen_path), it doesn't work. (both pops the bottomSheet and pops to previous screen)
After a little dig into modal_bottom_sheet, I found out it use Navigator.of(context).push(Route)
to show the bottomSheet, but when using qlevar_router, how to tell the navigator to handle the 'back button' correctly?
Hi @westlinkin, Thanks for your feedback, I have found the problem and working on it
@SchabanBo
Thanks. I found a workaround, back_button_interceptor is needed. In every screen, check if a ModalRoute is active, if so, pops that ModalRoute and consumes the back button event; if not, do not do anything.
ModalRoute.of(context)?.isCurrent != true
means a ModalRoute is presented (need to intercept the back button event)
Exactly @westlinkin, that was the problem. When you add a buttom_sheet, this is done with Navigator.push
. In this case, qlevar_router does not know that there is something else that should be removed and removes the last route. So I am trying to add a way for qlevar_router to check first if there are any other routes added from outside the package.
But it is good that you have found something to fix it now.
Hi @anandrajak2, What can not pop out, could you add an example?