Navigator routes Clear the stack of flutter
Full clean of Navigator's history and navigate to new route:
void _logout() {
Navigator.pushNamedAndRemoveUntil(context, "/newRouteName", (r) => false);
}
Use Navigator.popUntil
.
void _logout() {
Navigator.popUntil(context, ModalRoute.withName('/login'));
}