1+ import 'package:app/main/init.dart' ;
12import 'package:app/presentation/ui/pages/home/home_page.dart' ;
23import 'package:app/presentation/ui/pages/login/login_page.dart' ;
34import 'package:app/presentation/ui/pages/sign_up/sign_up_page.dart' ;
@@ -42,7 +43,7 @@ class Routers {
4243 }) =>
4344 GoRouter (
4445 initialLocation: initialLocation ??
45- (context. read <AuthCubit >().isLoggedIn ()
46+ (getIt <AuthCubit >().isLoggedIn ()
4647 ? Routes .app.path
4748 : Routes .auth.path),
4849 routes: [
@@ -56,7 +57,7 @@ class Routers {
5657 switch (appState.data) {
5758 case AuthStateAuthenticated _:
5859 debugPrint ('User is authenticated: ${state .fullPath }' );
59- if (state.fullPath? .contains (Routes .app.path) ??
60+ if (state.fullPath? .startsWith (Routes .app.path) ??
6061 false ) {
6162 // Already navigating to app, do nothing
6263 return ;
@@ -67,7 +68,7 @@ class Routers {
6768 case AuthStateUnauthenticated _:
6869 debugPrint (
6970 'User is unauthenticated: ${state .fullPath }' );
70- if (state.fullPath? .contains (Routes .auth.path) ??
71+ if (state.fullPath? .startsWith (Routes .auth.path) ??
7172 false ) {
7273 // Already navigating to auth, do nothing
7374 return ;
@@ -90,7 +91,7 @@ class Routers {
9091 name: Routes .auth.name,
9192 path: Routes .auth.path,
9293 redirect: (context, state) {
93- if (context. read <AuthCubit >().isLoggedIn ()) {
94+ if (getIt <AuthCubit >().isLoggedIn ()) {
9495 return Routes .app.path;
9596 }
9697 return null ;
@@ -113,7 +114,7 @@ class Routers {
113114 name: Routes .app.name,
114115 path: Routes .app.path,
115116 redirect: (context, state) {
116- if (! context. read <AuthCubit >().isLoggedIn ()) {
117+ if (! getIt <AuthCubit >().isLoggedIn ()) {
117118 return Routes .auth.path;
118119 }
119120 return null ;
0 commit comments