pushReplacement function

Future<Widget?> pushReplacement(
  1. BuildContext context,
  2. Widget route
)

To replace screen on to the stack use pushReplacement and pass the context,Screen/Page/Widget To replace a named or onGenerate route please use pushReplacementNamed and pass the context,Route,arguments if any

Implementation

Future<Widget?> pushReplacement(BuildContext context, Widget route) =>
    Navigator.pushReplacement(
      context,
      MaterialPageRoute<Widget>(
        builder: (_) => route,
      ),
    );