How to Signout a user in Flutter with Firebase authentication
You need to have an Instances of FirebaseAuth
final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
And Then
_signOut() async {
await _firebaseAuth.signOut();
}
Firebase auth's signOut
method is asynchronous. You should make your _signOut
method async
.
Future<void> _signOut() async {
await FirebaseAuth.instance.signOut();
}
so that the call to runApp
occurs after the user is signed out.
You should also call _googleSignIn.signOut()
when logging out if you want signIn
to present the user with an authentication dialog instead of silently and automatically re-using the current Google user.