WinterRouter constructor

WinterRouter({
  1. List<Route>? routes,
  2. RouterConfig? config,
  3. String basePath = '',
})

Implementation

factory WinterRouter({
  List<Route>? routes,
  RouterConfig? config,
  String basePath = '',
}) {
  List<Route> nonNullRoutes = [];
  RouterConfig nonNullConfig = config ?? RouterConfig();

  for (var route in (routes ?? [])) {
    if (isValidUri(route.path)) {
      nonNullRoutes.add(route);
    } else {
      nonNullConfig.onInvalidUrl(route);
    }
  }
  nonNullConfig.onLoadedRoutes(nonNullRoutes);

  return WinterRouter.build(
    config: nonNullConfig,
    routes: nonNullRoutes,
    basePath: basePath,
  );
}