offUntil<T> method

Future<T?>? offUntil<T>(
  1. Route<T> page,
  2. RoutePredicate predicate, {
  3. int? id,
})

Navigation.pushAndRemoveUntil() shortcut.

Push the given page, and then pop several pages in the stack until predicate returns true

id is for when you are using nested navigation, as explained in documentation

Obs: unlike other get methods, this one you need to send a function that returns the widget to the page argument, like this: Get.offUntil(GetPageRoute(page: () => HomePage()), predicate)

predicate can be used like this: Get.offUntil(page, (route) => (route as GetPageRoute).routeName == '/home') to pop routes in stack until home, or also like this: Get.until((route) => !Get.isDialogOpen()), to make sure the dialog is closed

Implementation

Future<T?>? offUntil<T>(Route<T> page, RoutePredicate predicate, {int? id}) {
  // if (key.currentState.mounted) // add this if appear problems on future with route navigate
  // when widget don't mounted
  return global(id).currentState?.pushAndRemoveUntil<T>(page, predicate);
}