DocumentSnapshot doc = await userRef.document(widget.currentuserId).get();
user = User.fromDocument(doc);
bioController.text = user.bio;
usernameController.text = user.username;
displayNameController.text = user.displayName;
如何在流数据中进行转换?
我尝试了这个,但是有一些错误我无法弄清楚:
Stream<DocumentSnapshot> doc = await userRef.document(widget.currentuserId).snapshots();
user = User.fromDocument(doc);
bioController.text = user.bio;
usernameController.text = user.username;
displayNameController.text = user.displayName;
最佳答案
如果使用get()
,则得到Future<DocumentSnapshot>
,则需要使用snapshots
。
Stream<DocumentSnapshot> stream = userRef.document(widget.currentuserId).snapshots();
stream.listen((snapshot) {
// snapshot is DocumentSnapshot
});
关于flutter - 如何在flutter中将文档快照转换为Stream数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62105300/