The method 'signInWithGoogle' isn't defined for the class 'FirebaseAuth'

I had the same problem and found the example in the firebase_auth

https://github.com/flutter/plugins/blob/master/packages/firebase_auth/example/lib/main.dart

Try replacing your handleSignIn method with

  Future<FirebaseUser> _handleSignIn() async {
    GoogleSignInAccount googleUser = await _googleSignIn.signIn();
    GoogleSignInAuthentication googleAuth = await googleUser.authentication;
    final AuthCredential credential = GoogleAuthProvider.getCredential(
      accessToken: googleAuth.accessToken,
      idToken: googleAuth.idToken,
    );
    final FirebaseUser user = await _auth.signInWithCredential(credential);
    print("signed in " + user.displayName);
    return user;
  }

It may be that the signInWithGoogle method is valid but I couldn't find anything on it and the above code works for me.


This implementation has been changed again, so now the _auth.signInWithCredential returns an AuthResult instance, and you can access to the user as a property of this object.

Future<FirebaseUser> _handleSignIn() async {
  GoogleSignInAccount googleUser = await _googleSignIn.signIn();
  GoogleSignInAuthentication googleAuth = await googleUser.authentication;
  final AuthCredential credential = GoogleAuthProvider.getCredential(
    accessToken: googleAuth.accessToken,
    idToken: googleAuth.idToken,
  );
  final AuthResult authResult = await _auth.signInWithCredential(credential);
  FirebaseUser user = authResult.user;
  print("signed in " + user.displayName);
  return user;
}