Skip to content

[google_sign_in] Add discussion of exceptions to the migration guide #171704

@qeepcologne

Description

@qeepcologne

What package does this bug report belong to?

google_sign_in

What target platforms are you seeing this bug on?

Android

Have you already upgraded your packages?

Yes

Steps to reproduce

GoogleSignInAccount googleUser = await GoogleSignIn.instance.authenticate();
windows with selecting the google account opens
close that window

Expected results

migration guide should also mention:

GoogleSignIn.instance.authenticate() throws GoogleSignInException with code GoogleSignInExceptionCode.canceled

instead of
returning null

when the user closes the window/cancel the process

Code sample

Future<OAuthCredential?> _googleLoginCredential() async {
  try {
    final GoogleSignInAccount googleUser = await GoogleSignIn.instance.authenticate();
    final GoogleSignInAuthentication googleAuth = googleUser.authentication;
    return GoogleAuthProvider.credential(idToken: googleAuth.idToken);
  } catch  (e) {
    if (e is GoogleSignInException){
      if (e.code == GoogleSignInExceptionCode.canceled){
        return null;
      }
    }
    rethrow;
  }
}

Metadata

Metadata

Labels

P2Important issues not at the top of the work listd: api docsIssues with https://api.flutter.dev/p: google_sign_inThe Google Sign-In pluginpackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions