push<T extends Object?, R extends Object?> method
Implementation
Future<T?> push<T extends Object?, R extends Object?>(
dynamic route, {
String? name,
Map<String, dynamic>? arguments,
Flag flag = Flag.none,
RoutePredicate? predicate,
R? result,
AnimType type = AnimType.slideLeft,
}) {
if (flag == Flag.replacement) {
if (route is String) {
return Navigator.pushReplacementNamed(
context,
route,
result: result,
arguments: arguments,
);
} else if (route is Widget) {
return Navigator.pushReplacement(
context,
result: result,
AppRoute<T>(
name: name,
arguments: arguments,
child: route,
),
);
} else {
return Navigator.pushNamed(context, "error");
}
} else if (flag == Flag.clear) {
if (route is String) {
return Navigator.pushNamedAndRemoveUntil(
context,
route,
predicate ?? (value) => false,
arguments: arguments,
);
} else if (route is Widget) {
return Navigator.pushAndRemoveUntil(
context,
AppRoute<T>(
name: name,
arguments: arguments,
child: route,
),
predicate ?? (route) => false);
} else {
return Navigator.pushNamed(context, "error");
}
} else {
if (route is String) {
return Navigator.pushNamed(
context,
route,
arguments: arguments,
);
} else if (route is Widget) {
return Navigator.push(
context,
AppRoute<T>(
name: name,
arguments: arguments,
child: route,
),
);
} else {
return Navigator.pushNamed(context, "error");
}
}
}