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. PageTransitionSettings? pageTransitionSettings,
})

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,
    PageTransitionSettings? pageTransitionSettings}) async {
  assert(navigationType != NavigationType.pushAndRemoveUntil ||
      removeUntilPredicate != null);

  _checkAndThrowRouteNotFound(name, args, navigationType);

  return await _navigate(name, args, navigationType, result,
          removeUntilPredicate, pageTransitionType, pageTransitionSettings)
      .then((value) => value as T);
}