我收到错误消息: StateError(错误状态:无法在不存在的DocumentSnapshotPlatform上获取字段)
Future getUserInterests(userId) async {
User currentUser = User();
await _firestore.collection('users').doc(userId).get().then((user) {
currentUser.photo = user.get('name');
currentUser.photo = user.get('photoUrl');
currentUser.gender = user.get('gender');
currentUser.subject = user.get('subject');
});
return currentUser;
}
名称字段确实存在于我的Firebase收藏夹中
这是我数据库的图像,请忽略性别如何表示第十个笑声
答案 0 :(得分:3)
您需要执行以下操作:
currentUser.name = user.data()['name'];
currentUser.photo = user.data()['photoUrl'];
currentUser.gender = user.data()['gender'];
currentUser.subject = user.data()['subject'];