updateProfile method

Future<void> updateProfile({
  1. ProfileUpdate<String>? displayName,
  2. ProfileUpdate<Uri>? photoUrl,
})

Updates certain aspects of the users profile.

Only the displayName and the photoUrl can be updated. For each of these parameters, you have one of three options:

  • Pass null to (or leave out the) parameter to keep it as it is
  • Pass ProfileUpdate.update() to change the property to a new value
  • Pass ProfileUpdate.delete() to remove the property. This will erase the data on firebase servers and set them to null.

If the request fails, an AuthException will be thrown. The updated profile can be fetched via getDetails().

Implementation

Future<void> updateProfile({
  ProfileUpdate<String>? displayName,
  ProfileUpdate<Uri>? photoUrl,
}) =>
    api.updateProfile(
      ProfileUpdateRequest(
        idToken: _idToken,
        displayName: displayName?.updateOr(),
        photoUrl: photoUrl?.updateOr(),
        deleteAttribute: [
          if (displayName?.isDelete ?? false) DeleteAttribute.DISPLAY_NAME,
          if (photoUrl?.isDelete ?? false) DeleteAttribute.PHOTO_URL,
        ],
      ),
    );