Need example or solution idea about GetMiddleware implementation with FirebaseAuth #2312
Unanswered
pratamatama
asked this question in
Q&A
Replies: 1 comment
-
This works for with hot reload, as the user seems to be re-registered at some point and is not NULL. sub = _firebaseAuth.authStateChanges().listen((User? user) {
if (user != null) {
Get.offNamed( YOUR_ROUTE );
}
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi guys! I need help with auth middleware implementation using
firebase_auth
. I have tried so many attempts but none is working. The problem with my current implementation is that the user is redirecting to the login page everytime the app is reopened or the browser was refreshed.My current middleware implementation looks like this, and what I know is the
currentUser
is always giving me anull
result on page load.auth_middleware.dart
app_pages.dart
I once tried to use
GetxService
but it sometimes throws anavigation without context
error when I tried to run the app.The
user
getter is also always giving menull
. What I really get from this method is this happening because theauthStateChanges
stream is triggering theever
worker, eventhough the value is the same (null
). I am wondering if I could do something to make theever
worker not triggering in at the very first time the stream is binded. Can we do that?auth_service.dart
auth_middleware.dart
main.dart
I really appreciate any kind of help from the community! ><
Beta Was this translation helpful? Give feedback.
All reactions