Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating FirebaseUser DisplayName (email auth) isn't updating instance CurrentUser

This might be similar to this: FirebaseUser's profile is not updated

However, I'm not confident in my Flutter skills to be sure. I'm trying to update DisplayName in Firebase and then have the currentUser.displayName. The updateProfile seems to run just fine, but the currentUser doesn't update with the new displayName even after a reload() call.

I'm hoping anyone could tell me if I'm doing something wrong, or chalk it up to a bug in Firebase.

My code:

Future _update(FirebaseUser user, String displayName) async {
  UserUpdateInfo _updateData= new UserUpdateInfo();
  _updateData.displayName = displayName;
  await user.updateProfile(_updateData);
  await user.reload();
  setState(() {
    _currentDisplayName = user.displayName;
  });
}
like image 540
themene Avatar asked Nov 18 '18 15:11

themene


1 Answers

it work for me

FirebaseAuth.instance.currentUser().then((val) {
      UserUpdateInfo updateUser = UserUpdateInfo();
      updateUser.displayName = myFullName;
      updateUser.photoUrl = picURL;
      val.updateProfile(updateUser);
    });
like image 56
handi deyana Avatar answered Nov 04 '22 22:11

handi deyana