Hi @felangel,
I have these pages in my architecture:
In all pages, I need InitBloc, it is a general bloc I use in main.dart to route the user to the specific page according to the current situation of user (stored in db) even user reopen the app:
UserIsNotExist, go to Init Page.UserIsRegistering, go to Auth Page.UserVerified, go to Home Page.The Auth flow consist of two registration and verification pages.
In the registration page I need RegisterBloc and in the verification page I need both RegisterBloc and VerifyBloc blocs.
In The Home page, I need only HomeBloc and also optional InitBloc.
Now this is sample_auth for that, but I have two issues with that:
I would like in the verification page, User can back to the registration page with back button of phone. But when I pressed the back button, Intro pages shown. (It seems Registration page is not pushed on the stack)
In the Verification page, when I navigate to the Home page, it's not work and show the Registration page instead, beacuse I used onGenerateRoute approach you mentioned here and main route is ignored.
Thanks a lot as all your codes and your active community.
Hi, @omidraha
could you provide your a minimal reproducible code sample how are you using it and describe desired result?
Hi,
I said on the above post.
This sample_auth is for minimal reproducible code.
And my problems are:
I would like in the verification page, User can back to the registration page with back button of phone. But when I pressed the back button, Intro pages shown. (It seems Registration page is not pushed on the stack)
In the Verification page, when I navigate to the Home page, it's not work and show the Registration page instead, beacuse I used onGenerateRoute approach you mentioned here and main route is ignored.
Hi, @omidraha
Sorry, I didn鈥檛 see it before, I cloned the project later to check it out.
Hi, @omidraha
Use Navigator.of(context, rootNavigator: true) can solve the problem, this problem has nothing to do with bloc.
@felangel close the issue, plz
Hi,
I tired now, and you right this Navigator.of(context, rootNavigator: true) fixed the 2 problem,
But how about first one:
verification page, User can back to the registration page with back button of phone. But when I pressed the back button, Intro pages shown. (It seems Registration page is not pushed on the stack)Hi, @omidraha
Use WillPopScope to control the route can fix.
Since I use mac to run, I am sorry to ignore the back button.
Hi,
I tried it, but because of both registration and verification pages are in one nested navigation, and because I used onGenerateRoute approach you mentioned here to have two bloc on this auth flow, It seems both registeration and verification pages are in the stack as one route name, and I can't separate them on onWillPop method.
Finally I fixed it.
Thanks.
Most helpful comment
Finally I fixed it.
Thanks.