route method

NyRouterRoute route(
  1. String name,
  2. NyRouteView view, {
  3. PageTransitionType? transition,
  4. PageTransitionSettings? pageTransitionSettings,
  5. List<NyRouteGuard>? routeGuards,
  6. bool initialRoute = false,
  7. bool unknownRoute = false,
  8. bool authenticatedRoute = false,
})

Add a new route with a widget.

Implementation

NyRouterRoute route(String name, NyRouteView view,
    {PageTransitionType? transition,
    PageTransitionSettings? pageTransitionSettings,
    List<NyRouteGuard>? routeGuards,
    bool initialRoute = false,
    bool unknownRoute = false,
    bool authenticatedRoute = false}) {
  NyRouterRoute nyRouterRoute = NyRouterRoute(
    name: name,
    view: view,
    pageTransitionType: transition,
    pageTransitionSettings: pageTransitionSettings,
    routeGuards: routeGuards,
    initialRoute: initialRoute,
    unknownRoute: unknownRoute,
    authPage: authenticatedRoute,
  );
  _addRoute(nyRouterRoute, unknownRoute: unknownRoute);

  assert(
      _routeNameMappings.entries
              .where((element) => element.value.getInitialRoute() == true)
              .length <=
          1,
      'Your project has more than one initial route defined, please check your router file.');

  return nyRouterRoute;
}