pushReplacement function
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,
),
);