Is it possible to use Navigator.popUntil with routes that do not have fixed names?
I have a route created the following way:
final _key_homepage =
You should add a setting when pushing your route; with a custom name
Navigator.pushReplacement(
context,
MaterialPageRoute(
settings: RouteSettings(name: "Foo"),
builder: ...,
),
);
Then you can use popUntil
as you'd do with named routes
Navigator.popUntil(context, ModalRoute.withName("Foo"))
If you do not use named routes or we want to the navigator to First active, you can use
Navigator.of(context).popUntil((route) => route.isFirst)