关于Firestore的读取数据示例 this link我不明白为什么需要包含 de snapshot.hasData 来证明文档不存在。
if (snapshot.hasData && !snapshot.data!.exists) {
return Text("Document does not exist");
}
最佳答案
- .hasData是 AsyncSnapshot属性“返回[a]快照是否包含非空数据值。”
- .exists是 DocumentSnapshot属性“如果文档存在则返回 true。”
因此,调用 .hasData
来确保 Firestore 中的 DocumentSnapshot
可用(无论文档是否存在,都会返回 DocumentSnapshot
)并调用 .exists
来确定文档是否存在。
关于firebase - 了解 FirebaseFirestore 读取数据示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69163080/