The method 'UserUpdateInfo' isn't defined for the type 'AuthService'

Viewed 2022

I upgraded firebase_auth to ^0.18.0+1, and I am getting a few errors:

  • Undefined class 'AuthException'.
  • 'getCredential' is deprecated and shouldn't be used.
  • FirebaseAuth.instance.currentUser(): the expression doesn't evaluate to a function, so it can't be invoked.

I fixed the above but couldn't fix the below:

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

How can I resolve this? Should I just create a var and pass it in the updateInfo method?

1 Answers

FirebaseAuth api has changed with version 0.18.0. https://firebase.flutter.dev/docs/migration#authentication

UserUpdateInfo class has been removed in favor of named arguments and currentUser() method is no longer asynchronous.

Before:

          await FirebaseAuth.instance.currentUser().then((val) async {
            final userUpdateInfo = UserUpdateInfo();
            userUpdateInfo.displayName =
                '${appleIdCredential.fullName.givenName} ${appleIdCredential.fullName.familyName}';
            userUpdateInfo.photoUrl = 'define an url';
            await val.updateProfile(userUpdateInfo);
          });

After:

          await FirebaseAuth.instance.currentUser.updateProfile(
            displayName:
                '${appleIdCredential.fullName.givenName} ${appleIdCredential.fullName.familyName}',
            photoURL: 'define an url',
          );
Related