toAndRemoveUntil method

  1. @Deprecated("Avoid use this instance, you should use context.navigator.pushAndRemoveUntil(...)")
Future<void> toAndRemoveUntil(
  1. Widget page,
  2. bool predicate(
    1. Route
    ), {
  3. bool transition = true,
})

Do that:

Navigator.pushAndRemoveUntil(
 transition
    ? MaterialPageRoute(builder: (_) => page)
    : PageRouteBuilder(pageBuilder: (_, __, ___) => page),
 predicate
);

Implementation

@Deprecated(
    "Avoid use this instance, you should use context.navigator.pushAndRemoveUntil(...)")
Future<void> toAndRemoveUntil(
  Widget page,
  bool Function(Route<dynamic>) predicate, {
  bool transition = true,
}) async {
  await Navigator.pushAndRemoveUntil(
    this,
    _pageRoute(page, transition),
    predicate,
  );
}