replace method
Replace the current route of the navigator by pushing the given route and then disposing the previous route.
Implementation
Future<void> replace(
Widget screen, {
bool transparent = false,
bool isCupertino = false,
}) {
RouteSettings settings = RouteSettings(
name: screen.toString(),
);
if (transparent) {
// ignore: always_specify_types
return Navigator.of(this).pushReplacement(
TransparentRoute(
builder: (_) => screen,
settings: settings,
),
);
} else {
if (isCupertino) {
// ignore: always_specify_types
return Navigator.of(this).pushReplacement(
CupertinoPageRoute(
builder: (_) => screen,
settings: settings,
),
);
}
// ignore: always_specify_types
return Navigator.of(this).pushReplacement(
MaterialPageRoute(
builder: (_) => screen,
settings: settings,
),
);
}
}