In my flutter app I use this code to go to my dashboard page, but it fails to do so the first time and I get the debugLocked
error.
The launch page in the app is a Router that checks for shared preferences "sessionid" which, if set, takes the user directly to the Dashboard, else takes them to the login.
Without the below code, I get to my Dashboard just fine, using Navigator.pushReplacement()
but then, a back arrow appears on the appBar. This back button takes the app back to the Router.
I searched for answers on how to remove all screens from the navigator and the following was what I found.
Navigator.of(context).popUntil(ModalRoute.withName(Dashboard.id));
Using the above code gives me the debugLocked
error. Is there a solution to mitigate this problem? Or is there any other efficient way for me to remove screens from the context? Does setting automaticallyImplyLeading
to false
help somehow? Because this error only occurs after someone has logged in or signed up.
to remove all the previous routes use Navigator.pushAndRemoveUntil()
This can be another alternative, if you for some reason face a setState error.
navigationService.popUntil((_) => true);
navigationService.navigateTo(
'authentication',
);
basically i wait until the navigation finish setting everything and then call the navigateTo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With