我想在Firebase中获取文档的数据。我正在使用这个功能:
DocumentSnapshot docRef =
await Firestore.instance.collection("products").document("SF").get();
print(docRef.exists);
即使文档确实存在,docRef.exists也会返回“false”。
我认为它与auth流程有关,系统无法识别登录用户。
print(FirebaseAuth.instance.currentUser());
导致'Future <FirebaseUser>'的实例。
知道如何解决问题吗?
最好的祝福
编辑:
以下是来自firebase的规则:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
您定义安全规则的方式不正确。更改您的安全规则。
match /products/{document=**} {
allow read, write: if true;
}