Reputation: 115
I am using the firebase auth signout method but it doesnt seem to be working properly. when i click on the logout button, it is supposed to log the current user out. however, after doing so, the console does not indicate that the firebase auth signout method is actually working, none!
the app has a sysmte where if the user is online then they will always be redirected to the home page upon opening the app unless they log out from the app (which they will be redirected to the login page). and the app always redirects me to the home page when opening the app, hence it is clear that the firebase auth signout method is not working even after i hit the logout button
this is my logout method and it is in the Authentication
class
FirebaseAuth _auth = FirebaseAuth();
logOut() async {
return await _auth.signOut();
}
this is the callback and the logOutCurrentUser
function is called when i click the logout button
Authentication authentication = Authentication();
logOutCurrentUser(BuildContext context) {
try {
authentication.logOut();
Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LoginSignupToggle(true)), (route) => false);
}
catch (e) {
print(e.toString());
}
}
all in all, it seems like FirebaseAuth.instance.currentUser()
is still not null even after i hit the logout button which i expect it to be null after logging out
i have tried searching for an answer as much as i could but nothing seems to work for me
Upvotes: 2
Views: 4111
Reputation: 598740
My guess is that your sign-out is aborted because you're not waiting for it to finish. Since your logOut
is async
you need to use await
when calling it:
await authentication.logOut();
Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LoginSignupToggle(true)), (route) => false);
Upvotes: 2