Undefined class 'AuthResult' in Flutter
Solution 1
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>
Solution 2
They renamed the class AuthResult
to UserCredential
Solution 3
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.
Solution 4
In 2020 firebase_Auth_version(0.18.3+1), they changed from AuthResult
to UserCredential
, and GetCredentials
deprecated to credentials
.
Solution 5
AuthResult
has been changed to UserCredential
Berkay
Updated on May 07, 2022Comments
-
Berkay almost 2 years
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.
-
Tinus Jackson over 4 yearsHave you imported it from the firebase auth? if so then close your IDE maybe that will help?
-
-
connelblaze over 3 yearsyeah just checked that, tutorials will have to be updating too
-
Vega almost 3 yearsThis is exactly what the other answer says. Something new?
-
Vega almost 3 yearsCopied from stackoverflow.com/a/63518084/5468463