push<T extends Object?, R extends Object?> method
Future<T?>
push<T extends Object?, R extends Object?>(
- dynamic route, {
- bool? allowSnapshotting,
- Curve? animationCurve,
- int? animationTime,
- int? animationReserveTime,
- AnimationType? animationType,
- Map<
String, dynamic> arguments = const {}, - Color? barrierColor,
- bool? barrierDismissible,
- String? barrierLabel,
- bool? fullscreenDialog,
- String? name,
- Flag? flag,
- bool? maintainState,
- bool? opaque,
- RoutePredicate? predicate,
- R? result,
Implementation
Future<T?> push<T extends Object?, R extends Object?>(
dynamic route, {
bool? allowSnapshotting,
Curve? animationCurve,
int? animationTime,
int? animationReserveTime,
AnimationType? animationType,
Map<String, dynamic> arguments = const {},
Color? barrierColor,
bool? barrierDismissible,
String? barrierLabel,
bool? fullscreenDialog,
String? name,
Flag? flag,
bool? maintainState,
bool? opaque,
RoutePredicate? predicate,
R? result,
}) {
if (route is String) {
arguments.putIfAbsent("__app_route_config__", () {
return AppRouteConfig(
allowSnapshotting: allowSnapshotting,
animationCurve: animationCurve,
animationTime: animationTime,
animationReserveTime: animationReserveTime,
animationType: animationType,
barrierColor: barrierColor,
barrierDismissible: barrierDismissible,
barrierLabel: barrierLabel,
fullscreenDialog: fullscreenDialog,
maintainState: maintainState,
opaque: opaque,
);
});
if (flag == Flag.replacement) {
return Navigator.pushReplacementNamed(
context,
route,
result: result,
arguments: arguments,
);
} else if (flag == Flag.clear) {
return Navigator.pushNamedAndRemoveUntil(
context,
route,
predicate ?? (value) => false,
arguments: arguments,
);
} else {
return Navigator.pushNamed(
context,
route,
arguments: arguments,
);
}
} else if (route is Widget) {
AppRoute<T> mRoute = AppRoute<T>(
name: name,
allowSnapshotting: allowSnapshotting ?? true,
animationTime: animationTime ?? 500,
animationReserveTime: animationReserveTime,
animationType: animationType ?? AnimationType.slideRight,
arguments: arguments,
barrierColor: barrierColor,
barrierDismissible: barrierDismissible ?? false,
barrierLabel: barrierLabel,
animationCurve: animationCurve ?? Curves.decelerate,
fullscreenDialog: fullscreenDialog ?? false,
maintainState: maintainState ?? true,
opaque: opaque ?? true,
builder: (_) => route,
);
if (flag == Flag.replacement) {
return Navigator.pushReplacement(
context,
result: result,
mRoute,
);
} else if (flag == Flag.clear) {
return Navigator.pushAndRemoveUntil(
context,
mRoute,
predicate ?? (route) => false,
);
} else {
return Navigator.pushNamed(context, "error");
}
} else {
return Navigator.pushNamed(context, "error");
}
}