Member-only story

Flutter — Undefined class ‘FirebaseUser’

In the newest version of firebase_auth, the class FirebaseUser was changed to User

Flutter Developer
1 min readSep 14, 2021

--

Starting from Version firebase_auth 0.18.0:

In the newest version of firebase_auth, the class FirebaseUser was changed to User, and the class AuthResult was changed to UserCredential. Therefore change your code to the following:

Future<User> currentUser() async {
final GoogleSignInAccount account = await googleSignIn.signIn();
final GoogleSignInAuthentication authentication =
await account.authentication;
final GoogleAuthCredential credential = GoogleAuthProvider.credential(
idToken: authentication.idToken,
accessToken: authentication.accessToken);
final UserCredential authResult =
await _auth.signInWithCredential(credential);
final User user = authResult.user;
return user;
}

FirebaseUser changed to User

AuthResult changed to UserCredential

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

onAuthStateChanged which notifies about changes to the user's sign-in state was replaced…

--

--

Flutter Developer
Flutter Developer

Written by Flutter Developer

Flutter and Native Android developer

No responses yet