28 lines
659 B
Dart
28 lines
659 B
Dart
import 'package:flutter/cupertino.dart' hide RouterConfig;
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import 'config/route_paths.dart';
|
|
import 'config/router_config.dart';
|
|
import 'modules/home_routes.dart';
|
|
|
|
List<RouterConfig> routeConfigs = [...homeRoutes];
|
|
|
|
//for循环遍历
|
|
List<RouteBase> routes = routeConfigs.map((item) {
|
|
return GoRoute(
|
|
path: item.path,
|
|
builder: (context,state){
|
|
return item.child(state);
|
|
}
|
|
);
|
|
}).toList();
|
|
|
|
GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
|
|
|
//变量命名
|
|
GoRouter goRouter = GoRouter(
|
|
navigatorKey: navigatorKey,
|
|
initialLocation: RoutePaths.home,
|
|
routes: routes,
|
|
);
|