navigate<T> method
Function used to navigate pages.
name
is the route name that was registered using addRoute
.
args
are optional arguments that can be passed to the next page.
To retrieve these arguments use args
method on NyRouterRoute.
navigationType
can be specified to choose from various navigation
strategies such as NavigationType.push, NavigationType.pushReplace,
NavigationType.pushAndRemoveUntil.
removeUntilPredicate
should be provided if using
NavigationType.pushAndRemoveUntil strategy.
Implementation
Future<T> navigate<T>(String name,
{BaseArguments? args,
NavigationType navigationType = NavigationType.push,
dynamic result,
bool Function(Route<dynamic> route)? removeUntilPredicate,
PageTransitionType? pageTransitionType,
Duration transitionDuration = const Duration(milliseconds: 300)}) {
assert(navigationType != NavigationType.pushAndRemoveUntil ||
removeUntilPredicate != null);
_checkAndThrowRouteNotFound(name, args, navigationType);
return _navigate(name, args, navigationType, result, removeUntilPredicate,
pageTransitionType, transitionDuration)
.then((value) => value as T);
}