firebase - Flutter 文档快照

标签 firebase dart flutter google-cloud-firestore

我正在尝试从 firebase 的 DocumentSnapshot 中获取数据。

Firestore.instance.collection('products').document("Lucius_Malfoys_Zauberstab").get().then((DocumentSnapshot ds) {
          print(ds.exists);
        });

这个方法完全可以正常工作并返回 true,但是:

      var keys =  ["Lucius_Malfoys_Zauberstab"];


     String id =  keys[0];
     print(id); ---> prints Lucius_Malfoys_Zauberstab


     Firestore.instance.collection('products').document(id).get().then((DocumentSnapshot ds) {
      print(ds.exists);
      });

返回错误...

有没有人知道为什么会这样? 这只是我的应用程序中的一个小问题,但我很好奇为什么会这样。只是为了理解。谢谢!

编辑:

这是购物车集合的屏幕截图:

enter image description here

这是产品集合的屏幕截图:

enter image description here

最佳答案

我无法重现问题。此时我能做的最好的事情就是向您展示我所做的:

enter image description here

第一次打印 false 是在我拿到文档之前。然后我创建了文档,再次运行 _test,它打印了 true

如果我删除我对 /55652643/{document} 的权限,则不会到达 print 语句,而是我得到一个堆栈跟踪,表明权限已被拒绝.

关于firebase - Flutter 文档快照,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55652643/

相关文章:

dart - 安装后,Flutter 发布的应用程序无法在设备上运行

flutter - 使用JsonPlaceHolder时出现错误: The argument type 'String' can't be assigned to the parameter type 'Uri' .

node.js - 当我尝试初始化 Firebase 应用程序时,为什么 Google Cloud Functions 会抛出 "Invalid value for config firebase.databaseURL"错误?

firebase - 如何传递应用程序功能?

javascript - 云函数中的 cors 错误

dart - 如何在Dart Polymer中创建模态和非模态对话框

firebase - 由于权限问题,无法访问 Firebase 中的 Cloud Firestore

cookies - Dartium 不在 websocket 握手时发送 httpOnly cookie

android - 即使在删除权限后也需要更新位置权限声明 - 应用内容 - 拒绝 Google Play 控制台

flutter - 如何设置复选框边距或填充右边的图像和文本