pushReplacement static method
Future
pushReplacement({
- required BuildContext context,
- required Widget screen,
- bool isCupertinoPush = true,
Replaces the current route with a new one.
context: The build context from which to navigate.
screen: The widget to display as the new screen.
isCupertinoPush: If true, uses a CupertinoPageRoute for iOS-style
transitions. Otherwise, uses a MaterialPageRoute. Defaults to true.
Implementation
static Future pushReplacement({
required BuildContext context,
required Widget screen,
bool isCupertinoPush = true,
}) async {
if (isCupertinoPush) {
return Navigator.pushReplacement(
context,
CupertinoPageRoute(
builder: (context) {
return screen;
},
),
);
} else {
return Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) {
return screen;
},
),
);
}
}