Flutter Firebase.signInWithGoogle method not found

前端 未结 3 1217
星月不相逢
星月不相逢 2020-12-11 07:42

I am trying to add Google Authentication in my Flutter Application. But my Android studio is not able to find the method signInWithGoogle under Fire

3条回答
  •  星月不相逢
    2020-12-11 08:08

    check out the example provided in the firebase_auth github repo https://github.com/flutter/plugins/blob/master/packages/firebase_auth/example/lib/main.dart#L70

    Future _testSignInWithGoogle() async {
        final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
        final GoogleSignInAuthentication googleAuth =
            await googleUser.authentication;
        final AuthCredential credential = GoogleAuthProvider.getCredential(
          accessToken: googleAuth.accessToken,
          idToken: googleAuth.idToken,
        );
    
        final AuthResult authResult = await _auth.signInWithCredential(credential);
        final FirebaseUser user = authResult.user;
        assert(user.email != null);
        assert(user.displayName != null);
        assert(!user.isAnonymous);
        assert(await user.getIdToken() != null);
    
        final FirebaseUser currentUser = await _auth.currentUser();
        assert(user.uid == currentUser.uid);
    
        return 'signInWithGoogle succeeded: $user';
    }
    

提交回复
热议问题