Reputation: 71
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
Upvotes: 2
Views: 65
Reputation: 4109
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}');
Upvotes: 1