This commit is contained in:
cxc
2023-02-07 17:28:01 +08:00
parent ac65c1dec0
commit 06ff4a41f4
25 changed files with 537 additions and 184 deletions

View File

@ -1,16 +1,32 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:momo/material/home.dart';
import 'package:momo/material/login.dart';
class MyMaterialRouterConfig {
static GoRouter router = GoRouter(
routes: <RouteBase>[
GoRoute(
path: '/',
builder: (BuildContext context, GoRouterState state) {
return HomePage();
},
),
],
);
late GoRouter router;
MyMaterialRouterConfig(String? token) {
router = GoRouter(
routes: <RouteBase>[
GoRoute(
path: '/',
builder: (BuildContext context, GoRouterState state) {
return const HomePage();
},
redirect: (BuildContext context, GoRouterState state) {
if (token == null || token.isEmpty) {
return '/login';
}
return null;
}),
GoRoute(
path: "/login",
builder: (BuildContext context, GoRouterState state) {
return const LoginPage();
},
)
],
);
}
}