Home > OS >  flutter pushNamedAndRemoveUntil works on android but not on iOS
flutter pushNamedAndRemoveUntil works on android but not on iOS

Time:03-31

The following code works on android but not on iOS

Navigator.of(context)
    .pushNamedAndRemoveUntil('/login', (Route<dynamic> route) => false);

Any idea, solution?

CodePudding user response:

In Navigation 2 of Flutter you can use only go or push with define of all routes. By type only context.go(nameOfRoute) or context.push(nameOfRoute). The first remove screen from stack, the second save before move. GoRoutes Essay

CodePudding user response:

You can use pushAndRemoveUntil. It takes class. It is working on my project. For example;

Navigator.of(context).pushAndRemoveUntil(
             CupertinoPageRoute(
                   builder: (context) => Login()),
                   (_) => false,);
  • Related