2
Future<bool> signupwithemail(
    String emailS, String passwordS, String nameS) async {
  AuthResult result = await _auth.createUserWithEmailAndPassword(
      email: emailS, password: passwordS);
  FirebaseUser user = result.user;
  var info = new UserUpdateInfo();
  info.displayName = nameS;
  await user.updateProfile(info);
  await user.reload();
  uid = user.uid;
  email = user.email;
  name = user.displayName;
}

my implementation doesnt work,i always get the name as null,can someone point out my error

1
  • its not registering the displayName,i am always getting null as the name Commented Apr 23, 2020 at 16:37

1 Answer 1

1

You are getting the name of the old user not the updated one

try this:

            UserUpdateInfo userUpdateInfo = UserUpdateInfo()..displayName='hello';
            await user.updateProfile(userUpdateInfo);
            print('current user is ${(await _firebaseAuth.currentUser()).displayName}');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.