pongpat kummayee
pongpat kummayee

Reputation: 53

Firebase : The method 'getCredential' isn't defined for the type 'GoogleAuthProvider'

i have the following problem. i'm new in flutter and firebase, how i can fix it. thanks

void _handleFirebase() async {
    GoogleSignInAuthentication googleAuth = await _currentUser.authentication;
final AuthCredential credential = GoogleAuthProvider.getCredential(
    idToken: googleAuth.idToken, accessToken: googleAuth.accessToken);

final FirebaseUser firebaseUser =
    await firebaseAuth.signInWithCredential(credential);

if (firebaseUser != null) {
  print('Login');
}

and the problem show

The method 'getCredential' isn't defined for the type 'GoogleAuthProvider'. Try correcting the name to the name of an existing method, or defining a method named 'getCredential'.

here is my pubspec.yaml

 cupertino_icons: ^1.0.2
  firebase_auth: ^1.0.0
  google_sign_in: ^5.0.0
  firebase_database: ^6.1.0
  rflutter_alert: ^1.1.0

Upvotes: 5

Views: 2869

Answers (1)

blokberg
blokberg

Reputation: 994

getCredential is deprecated. You should use credential.

GoogleAuthProvider.credential(
   idToken: googleAuth.idToken, 
   accessToken: googleAuth.accessToken,
);

Upvotes: 15

Related Questions