【问题标题】:How to add additonal user data like displayName in firebase using flutter?如何使用颤振在firebase中添加其他用户数据,如displayName?
【发布时间】:2020-04-23 16:28:14
【问题描述】:
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;
}

我的实现不起作用,我总是将名称设为空,有人可以指出我的错误

【问题讨论】:

  • 它没有注册 displayName,我总是得到 null 作为名称

标签: firebase flutter firebase-authentication


【解决方案1】:

你得到的是旧用户的名字而不是更新的用户

试试这个:

            UserUpdateInfo userUpdateInfo = UserUpdateInfo()..displayName='hello';
            await user.updateProfile(userUpdateInfo);
            print('current user is ${(await _firebaseAuth.currentUser()).displayName}');

【讨论】:

    猜你喜欢
    • 2020-12-31
    • 2019-01-19
    • 2022-11-12
    • 1970-01-01
    • 2019-06-04
    • 2020-02-16
    • 2019-06-11
    • 2021-08-01
    相关资源
    最近更新 更多