Berkay
Berkay

Reputation: 1068

Undefined class 'AuthResult' in Flutter

I have been trying to implement Google login screen using Flutter.

final AuthResult authResult = await _auth.signInWithCredential(credential);

The editor, for the line above, says:

Undefined class 'AuthResult'

How can I fix it? Any help would be very appreciated.

Upvotes: 36

Views: 35094

Answers (7)

Kibrom Hs
Kibrom Hs

Reputation: 97

final UserCredential authResult = await _auth.signInWithCredential(credential);

Upvotes: 0

Abdallah Mustapha
Abdallah Mustapha

Reputation: 21

In 2021 firebase_auth_version of ^3.0.1, AuthException has also been change to FirebaseAuthException

Upvotes: 1

Harshil Patel
Harshil Patel

Reputation: 127

AuthResult has been changed to UserCredential

Upvotes: 5

Ahsan Khan
Ahsan Khan

Reputation: 271

In 2020 firebase_Auth_version(0.18.3+1), they changed from AuthResult to UserCredential, and GetCredentials deprecated to credentials.

Upvotes: 3

Nuqo
Nuqo

Reputation: 4081

Starting from Version firebase_auth 0.18.0:

FirebaseUser has been changed to User

AuthResult has been changed to UserCredential

GoogleAuthProvider.getCredential() has been changed to GoogleAuthProvider.credential()

onAuthStateChanged which notifies about changes to the user's sign-in state was replaced with authStateChanges()

currentUser() which is a method to retrieve the currently logged in user, was replaced with the property currentUser and it no longer returns a Future<FirebaseUser>

Upvotes: 80

Prabhashi Buddhima
Prabhashi Buddhima

Reputation: 1305

They renamed the class AuthResult to UserCredential

Upvotes: 89

Berkay
Berkay

Reputation: 1068

The problem was firebase_auth version that I added to pubspec.yaml.

Previous version I have been using: firebase_auth: ^0.11.1+8

Now: firebase_auth: ^0.15.2

This change on versions has fixed the problem.

Upvotes: 10

Related Questions