初始化
This commit is contained in:
27
lib/router/app_routes.dart
Normal file
27
lib/router/app_routes.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
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,
|
||||
);
|
||||
Reference in New Issue
Block a user