signInWithGoogle static method

Future<void> signInWithGoogle(
  1. BuildContext context
)

Implementation

static Future<void> signInWithGoogle(BuildContext context) async {
  if (kIsWeb) {
    await svc<AuthService>().signInWithPopup(GoogleAuthProvider());
  } else if (Platform.isWindows) {
    await _signInWithGoogleWindowsV2(context);
  } else {
    gsi.GoogleSignInAccount? googleUser =
        await gsi.GoogleSignIn.standard(scopes: ["email"]).signIn();
    gsi.GoogleSignInAuthentication? googleAuth =
        await googleUser?.authentication;

    if (googleAuth == null) {
      error("Google Auth is null!");
    }

    await svc<AuthService>().signIn(GoogleAuthProvider.credential(
      accessToken: googleAuth?.accessToken,
      idToken: googleAuth?.idToken,
    ));
  }
}