toReplacement method

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

Do that:

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

Implementation

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