【发布时间】:2020-01-12 03:35:53
【问题描述】:
有没有像我们在原生 android 中使用 UserProfileChangeRqeust() 一样在颤振中添加/更新 firebase 用户名和照片 url?
【问题讨论】:
标签: firebase flutter dart firebase-authentication
有没有像我们在原生 android 中使用 UserProfileChangeRqeust() 一样在颤振中添加/更新 firebase 用户名和照片 url?
【问题讨论】:
标签: firebase flutter dart firebase-authentication
是的,有。
收到FirebaseUser 后,您可以在对象上调用updateProfile() 方法以提供新的详细信息。此方法将接受UserUpdateInfo 类型的输入。
例如,
FirebaseUser user = await _auth.currentUser();
UserUpdateInfo userUpdateInfo = UserUpdateInfo();
userUpdateInfo.displayName = 'Ayush';
userUpdateInfo.photoUrl = '<my photo url>';
await user.updateProfile(userUpdateInfo);
【讨论】:
2021 年 2 月更新
这是更改用户displayName和photoURL的更新方式
void updateUserInfo() {
var user = FirebaseAuth.instance.currentUser;
user.updateProfile(displayName: "Abel", photoURL: "photoPath").then((value){
print("Profile has been changed successfully");
//DO Other compilation here if you want to like setting the state of the app
}).catchError((e){
print("There was an error updating profile");
});
}
您可以在官方 firebase flutter 文档中阅读更多相关信息。 here
【讨论】: