signInWithGoogle method missing
Got this compiler error from the loginpage.dart:
lib/loginpage.dart:110:57: Error: The method 'signInWithGoogle' isn't defined for the class 'firebase_auth::FirebaseAuth'.
Try correcting the name to the name of an existing method, or defining a method named 'signInWithGoogle'.
FirebaseAuth.instance.signInWithGoogle
Changing the code on line 109:
// From
FirebaseAuth.instance.signInWithGoogle(idToken: googleuser.idToken, accessToken: googleuser.accessToken).
// To
FirebaseAuth.instance.signInWithCustomToken(token: googleuser.idToken).
Allows the app to compile, but not sure if this the desired alternative and have yet to test on a device.
Following the firebase_auth you should be using
final AuthCredential credential = GoogleAuthProvider.getCredential( accessToken: googleAuth.accessToken, idToken: googleAuth.idToken, );
final FirebaseUser user = await _auth.signInWithCredential(credential); print("signed in " + user.displayName);
Instead of:
FirebaseAuth.instance.signInWithGoogle(idToken: googleuser.idToken, accessToken: googleuser.accessToken).
But now its again changed and the code will have an additional step, instead of the Firebase user, we get AuthResults, we have to extract the FirebaseUser from that
final AuthCredential credential = GoogleAuthProvider.getCredential( accessToken: googleAuth.accessToken, idToken: googleAuth.idToken, ); AuthResult authResults = await _auth.signInWithCredential(credential); FirebaseUser user = authResults.user;