Undefined class 'UserUpdateInfo' in Firebase_auth (Flutter 2020)

Viewed 3741

I am using Flutter with the 'Firebase_auth' package. While I am making the following signUp function, I get an error on the 'UserUpdateInfo'.

signup(CustomUser user, AuthNotifier authNotifier) async {


UserCredential userCredential = await FirebaseAuth.instance
      .createUserWithEmailAndPassword(email: user.email, password: user.password)
      .catchError((error) => print(error.code));



if (userCredential != null) {
    UserUpdateInfo updateInfo = UserUpdateInfo();
    updateInfo.displayName = user.displayName;

User firebaseUser = userCredential.user;

if (firebaseUser != null) {
  await firebaseUser.updateProfile(updateInfo);

  await firebaseUser.reload();

  print("Sign up: $firebaseUser");

  User currentUser = await FirebaseAuth.instance.currentUser();
  authNotifier.setUser(currentUser);
}}}

The following error is shown:

Undefined class 'UserUpdateInfo'

What can I do about it?

1 Answers

It seems like you've updated your Firebase_Auth package. UserUpdateInfo is now deprecated. Try this instead:

await FirebaseAuth.instance.currentUser.updateProfile(displayName:user.displayName);
Related