navigate<T> method

Future<T> navigate<T>(
  1. String name, {
  2. BaseArguments? args,
  3. NavigationType navigationType = NavigationType.push,
  4. dynamic result,
  5. bool removeUntilPredicate(
    1. Route route
    )?,
  6. PageTransitionType? pageTransitionType,
  7. Duration transitionDuration = const Duration(milliseconds: 300),
})

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);
}