基本完成
This commit is contained in:
28
lib/router/routes.dart
Normal file
28
lib/router/routes.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
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,
|
||||
);
|
||||
Reference in New Issue
Block a user