update dependence

This commit is contained in:
quantulr
2023-02-10 00:07:41 +08:00
parent 2aa59649a8
commit bd259d8303
9 changed files with 58 additions and 58 deletions

View File

@ -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();
},