offNamedUntil<T> method
Navigation.pushNamedAndRemoveUntil() shortcut.
Push the given named page
, and then pop several pages in the stack
until predicate
returns true
You can send any type of value to the other route in the arguments
.
id
is for when you are using nested navigation,
as explained in documentation
predicate
can be used like this:
Get.offNamedUntil(page, ModalRoute.withName('/home'))
to pop routes in stack until home,
or like this:
Get.offNamedUntil((route) => !Get.isDialogOpen())
,
to make sure the dialog is closed
Note: Always put a slash on the route name ('/page1'), to avoid unexpected errors
Implementation
Future<T?>? offNamedUntil<T>(
String page,
RoutePredicate predicate, {
int? id,
dynamic arguments,
Map<String, String>? parameters,
}) {
if (parameters != null) {
final uri = Uri(path: page, queryParameters: parameters);
page = uri.toString();
}
return global(id).currentState?.pushNamedAndRemoveUntil<T>(
page,
predicate,
arguments: arguments,
);
}