signInWithGoogle missing - FirebaseAuth

https://stackoverflow.com/questions/54508591/flutter-firebase-signinwithgoogle-method-not-found
This commit is contained in:
v-b-r
2019-12-26 23:27:36 +05:30
committed by GitHub
parent 4d23f7c82f
commit 577436e8ca

View File

@ -41,13 +41,15 @@ class AppState extends State<App> {
FirebaseAuth _auth = FirebaseAuth.instance;
try {
googleSignIn = GoogleSignIn();
GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();
GoogleSignInAuthentication gauth =
await googleSignInAccount.authentication;
FirebaseUser user = await _auth.signInWithGoogle(
accessToken: gauth.accessToken,
idToken: gauth.idToken,
GoogleSignInAccount googleUser = await googleSignIn.signIn();
final GoogleSignInAuthentication googleAuth =
await googleUser.authentication;
final AuthCredential credential = GoogleAuthProvider.getCredential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
final AuthResult authRes = await _auth.signInWithCredential(credential);
final FirebaseUser user = authRes.user;
setState(() {
_username = user.displayName;