add method

NyRouterRoute add(
  1. RouteView routeView, {
  2. PageTransitionType? transition,
  3. PageTransitionSettings? pageTransitionSettings,
  4. List<NyRouteGuard>? routeGuards,
  5. bool initialRoute = false,
  6. bool unknownRoute = false,
  7. bool authenticatedRoute = false,
})

Add a new route with a RouteView.

Implementation

NyRouterRoute add(RouteView routeView,
    {PageTransitionType? transition,
    PageTransitionSettings? pageTransitionSettings,
    List<NyRouteGuard>? routeGuards,
    bool initialRoute = false,
    bool unknownRoute = false,
    bool authenticatedRoute = false}) {
  NyRouterRoute nyRouterRoute = NyRouterRoute(
      name: routeView.$1,
      view: (context) => routeView.$2(context),
      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;
}