2

This looks possible duplicate of

Flutter Navigator.popUntil() with ModalRoute.withName() not working in profile and release mode

But it's not.

The above question resolves the issue of mismatched route names, But in my case, RouteSettings is always null.

Issue only for Android and only for Release/Profile builds

// Pushing the route
Navigator.of(context).push(
    MaterialPageRoute(
        builder: (context) {
             return ScreenA();
        },
        settings: RouteSettings(name: "screenA"),
    ),
);


// Popping until pushed route
Navigator.of(context).popUntil((route) {
    print(route.settings.name);
    // Here name and arguments are always null
    return route.settings.name == 'screenA';
});

UPDATE

Also tried with pushNamed with specified routes, and onGenerateRoute method. RouteSettings.name and RouteSettings.arguments is always null.

Flutter 1.22.5

Mehul Prajapati
  • 1,210
  • 2
  • 11
  • 29

1 Answers1

1

I was calling popUntil from inside a dialog. Like below example,

await showDialog(
  context: context,
  builder: (context) {
    return Dialog(
      child: Container(
        child: RaisedButton(
          onPressed: () {
            Navigator.of(context).popUntil((route) {
              return route.settings.name == 'screenA';
            });
          },
        ),
      ),
    );
  },
);

And the issue was because of await, Removing it works perfectly fine. If using await before showDialog RouteSettings.name comes null.

Mehul Prajapati
  • 1,210
  • 2
  • 11
  • 29