I want to restrict the user from viewing inner pages of the app after the user has logged out and has been redirected to the login page. What I know so far is the use of Navigator.pop(context) or Navigator.of(context).pop() to move back to a previous page. But this isn't fitting in the use case I have mentioned (or maybe I don't know).
CodePudding user response:
Navigator.of(context)
.pushNamedAndRemoveUntil('/login', (Route<dynamic> route) => false);
Navigator.pushNamedAndRemoveUntil this will clear all your stack behind after user will logout
CodePudding user response:
try pushAndRemoveUntil() instead of pop()
Navigator.of(context).pushAndRemoveUntil( MaterialPageRoute(builder: (ctx) => [Your login page]), (route) => false);
