Reputation: 34210
I have a login page that needs to shown for the first time, but once we entered the correct credential we land on home screen. This is working fine but problem starts when we press the back button which navigates to Login Screen again? Can we remove the login page from the back stack?
I am using the below navigation.
void _navigateToNextScreen(BuildContext context) {
Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => HomeScreen()));
}
Upvotes: 0
Views: 493
Reputation: 34210
pushReplacement Worked
void _navigateToNextScreen(BuildContext context) {
Navigator.of(context)
.pushReplacement(MaterialPageRoute(builder: (context) => WidgetOne()));
}
Upvotes: 2