getPureRouteInstall function

List<String> getPureRouteInstall(
  1. List<PureRouteInfo> pureRouteList
)

Implementation

List<String> getPureRouteInstall(List<PureRouteInfo> pureRouteList) {
  List<String> content = [];
  content.add('Map<String, WidgetBuilder> superRouterList = super.installRouters();');
  content.add('Map<String, WidgetBuilder> routers = {');
  Set<String> routeList = HashSet();
  for (PureRouteInfo route in pureRouteList) {
    String variantName = path2Variant(route.path);
    String arg = route.arg ? 'ModalRoute.of(context)!.settings.arguments' : '';
    routeList.add('$variantName : (context) => ${route.pageName}($arg),');
  }
  content.addAll(routeList);
  content.add('};');
  content.add('routers.addAll(superRouterList);');
  content.add('return routers;');
  return content;
}