Files
momo/lib/fluent/router.dart

50 lines
1.2 KiB
Dart
Raw Normal View History

2023-02-06 23:45:56 +08:00
import 'package:fluent_ui/fluent_ui.dart';
import 'package:go_router/go_router.dart';
import 'package:momo/fluent/home.dart';
2023-02-07 17:28:01 +08:00
import 'package:momo/fluent/login.dart';
2023-02-06 23:45:56 +08:00
class MyFluentRouterConfig {
2023-02-07 17:28:01 +08:00
late GoRouter router;
MyFluentRouterConfig(String? token) {
router = GoRouter(
routes: <RouteBase>[
GoRoute(
path: '/',
2023-02-06 23:45:56 +08:00
builder: (BuildContext context, GoRouterState state) {
2023-02-07 17:28:01 +08:00
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();
})
],
);
}
}
class TextLogin extends StatelessWidget {
const TextLogin({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return ScaffoldPage(
content: Center(
child: FilledButton(
child: Text("logi"),
onPressed: () {
context.go("/");
}),
),
);
}
2023-02-06 23:45:56 +08:00
}