import 'package:flutter/cupertino.dart';
import 'package:go_router/go_router.dart';

import 'modules/base.dart';
import 'config/route_paths.dart';
import 'config/route_type.dart';
import 'modules/serve.dart';

GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();

List<RouteType> routeConfigs = [...baseRoutes, ...serverRoutes];

//for循环遍历
List<RouteBase> routes = routeConfigs.map((item) {
  return GoRoute(
    path: item.path,
    builder: (context, state) {
      return item.child(state);
    },
  );
}).toList();

//变量命名
GoRouter goRouter = GoRouter(
  initialLocation: RoutePaths.splash,
  routes: routes,
  navigatorKey: navigatorKey,
);
