pushReplacement<T, X> method

Future<T?> pushReplacement<T, X>(
  1. Route<T> route, {
  2. X? result,
})

Equals to Navigator.of(context).pushReplacement() Just give it the route you want to push

Example

context.pushReplacement(
   MaterialPageRoute(builder: (context) => CounterPage()));

Implementation

Future<T?> pushReplacement<T, X>(
  Route<T> route, {
  X? result,
}) async =>
    Navigator.of(this).pushReplacement<T, X>(route, result: result);