fix
This commit is contained in:
@ -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();
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user