Navigator.pushAndRemoveUntil code example
Example: push and remove until flutter
//named
Navigator.of(context)
.pushNamedAndRemoveUntil('/login', (Route route) => false);
//not named
Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (context) =>
LoginScreen()), (Route route) => false),