Make flutter app force a user to choose an account with FirebaseAuth and GoogleSignInAuthentication
Use GoogleSignInAccount.disconnect() before signing out to revoke the previous authentication:
await _googleSignIn.disconnect();await FirebaseAuth.instance.signOut();
Harold's answer used to work for me, but recently the GoogleSignIn().currentUser appears null for some devices I tested, and then the disconnect function won't work. So, what solved that problem was ensuring it is signed in to Google.
final googleCurrentUser = GoogleSignIn().currentUser ?? await GoogleSignIn().signIn(); if (googleCurrentUser != null) await GoogleSignIn().disconnect().catchError((e, stack) { FirebaseCrashlytics.instance.recordError(e, stack); }); await _auth.signOut();
A simple way to go about it :-In your sign out method just use
_auth.signOut();
Now inside Google Sign In package, inside google_sign_in.dart
Future<GoogleSignInAccount> signIn() { final Future<GoogleSignInAccount> result = _addMethodCall(GoogleSignInPlatform.instance.signIn, canSkipCall: false); bool isCanceled(dynamic error) => error is PlatformException && error.code == kSignInCanceledError; return result.catchError((dynamic _) => null, test: isCanceled); }
Find the above method & set the canSkipCall parameter as false
final Future<GoogleSignInAccount> result = _addMethodCall(GoogleSignInPlatform.instance.signIn, canSkipCall: false);
This will enable choosing a user every time you try to sign in