Reputation: 41
i use
Navigator.push(context, MaterialPageRoute(builder: (context) => B()));
to push from A to B to C to D i need to pop back from D to B i also need to remove D and C form stack i used
Navigator.popUntil(context, (route) => route is B);
but it gives me a blank screen it works only with initial route, sloutions i found is to use
Navigator.pop();
twice
is there any alternative solutions?
Upvotes: 0
Views: 191
Reputation: 702
You can set route name.
Navigator.push(
context,
MaterialPageRoute(
settings: RouteSettings(name: '/B'),
builder: (context) => B(),
),
);
When you call popUntil
set parameter using this name.
Navigator.popUntil(
context,
ModalRoute.withName('/B'),
);
Upvotes: 1