Use popUntil
method of Navigator class.
e.g.
int count = 0;
Navigator.of(context).popUntil((_) => count++ >= 2);
However, I would recommend defining names for your routes and using popUntil
as it is designed as per docs.
Use popUntil
method of Navigator class.
e.g.
int count = 0;
Navigator.of(context).popUntil((_) => count++ >= 2);
However, I would recommend defining names for your routes and using popUntil
as it is designed as per docs.