我正在使用来自 firebase auth 的电子邮件和密码登录。
现在当我更改我的帐户时,显示的用户名将根据更改的帐户而改变。我想在不更改用户名的情况下发布多个帐户。
这是用于声明名称的代码:
Widget displayUserInformation(context, snapshot) {
final user = snapshot.data;
return Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
user.displayName,
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
),
],
);
}
注册码:
// Email & Password Sign Up
Future<String> createUserWithEmailAndPassword(
String email, String password, String name) async {
final authResult = await _auth.createUserWithEmailAndPassword(
email: email,
password: password,
);
// Update the username
await updateUserName(name, authResult.user);
return authResult.user.uid;
}
邮政编码:
static Future<void> sendPostInFirebase(String postID, String postContent,
MyProfileData displayName, String postImageURL) async {
String postFCMToken;
if (displayName.myFCMToken == null) {
SharedPreferences prefs = await SharedPreferences.getInstance();
postFCMToken = prefs.get('FCMToken');
} else {
postFCMToken = displayName.myFCMToken;
}
Firestore.instance.collection('thread').document(postID).setData({
'postID': postID,
'displayName': displayName.email,
'userThumbnail': displayName.myThumbnail,
'postTimeStamp': DateTime.now().millisecondsSinceEpoch,
'postContent': postContent,
'postImage': postImageURL,
'postLikeCount': 0,
'postCommentCount': 0,
'FCMToken': postFCMToken
});
}