update dependence
This commit is contained in:
@ -8,9 +8,12 @@ import 'package:momo/material/profile.dart';
|
||||
|
||||
class MyMaterialRouterConfig {
|
||||
late GoRouter router;
|
||||
final GlobalKey<NavigatorState> _rootNavigatorKey =
|
||||
GlobalKey<NavigatorState>();
|
||||
|
||||
MyMaterialRouterConfig(String? token) {
|
||||
router = GoRouter(
|
||||
navigatorKey: _rootNavigatorKey,
|
||||
initialLocation: "/",
|
||||
routes: <RouteBase>[
|
||||
ShellRoute(
|
||||
@ -19,29 +22,38 @@ class MyMaterialRouterConfig {
|
||||
content: child,
|
||||
);
|
||||
},
|
||||
routes: [
|
||||
routes: <RouteBase>[
|
||||
GoRoute(
|
||||
path: "/",
|
||||
name: "相册",
|
||||
pageBuilder: (BuildContext context, GoRouterState state) =>
|
||||
const NoTransitionPage(child: Gallery()),
|
||||
const NoTransitionPage(
|
||||
child: Gallery(),
|
||||
),
|
||||
redirect: (BuildContext context, GoRouterState state) {
|
||||
if (token == null || token.isEmpty) {
|
||||
return '/login';
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
},
|
||||
routes: <RouteBase>[
|
||||
GoRoute(
|
||||
path: "detail",
|
||||
name: "图片详情",
|
||||
pageBuilder:
|
||||
(BuildContext context, GoRouterState state) =>
|
||||
const NoTransitionPage(child: ImageDetail())),
|
||||
]),
|
||||
GoRoute(
|
||||
path: "/profile",
|
||||
name: "个人资料",
|
||||
pageBuilder: (BuildContext context, GoRouterState state) =>
|
||||
const NoTransitionPage(child: Profile())),
|
||||
GoRoute(
|
||||
path: "/detail",
|
||||
pageBuilder: (BuildContext context, GoRouterState state) =>
|
||||
const NoTransitionPage(child: ImageDetail())),
|
||||
],
|
||||
),
|
||||
GoRoute(
|
||||
path: "/login",
|
||||
name: "登录",
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const LoginPage();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user