loadRouter function

Future<Router> loadRouter (Future<List<RouterPath>> paths, List<RouterPlugin<Voyager>> plugins, { VoyagerFactory<Voyager> voyagerFactory })

Implementation

Future<Router> loadRouter(
    Future<List<RouterPath>> paths, List<RouterPlugin> plugins,
    {VoyagerFactory voyagerFactory}) {
  final router = voyagerFactory != null
      ? Router(voyagerFactory: voyagerFactory)
      : Router();

  plugins.forEach((plugin) {
    router.registerPlugin(plugin);
  });

  return paths.then((paths) {
    paths.forEach((path) {
      router.registerPath(path);
    });
  }).then((_) {
    return router;
  });
}