Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase 颤振快照_Firebase_Dart_Flutter_Google Cloud Firestore - Fatal编程技术网

Firebase 颤振快照

Firebase 颤振快照,firebase,dart,flutter,google-cloud-firestore,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_Zau

我正在尝试从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);
      });
返回false

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

编辑:

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

以下是产品系列的屏幕截图:


我无法重现这个问题。在这一点上,我所能做的就是向您展示我所做的:

false
的第一次打印是在我拿到文档之前。然后我创建了文档,再次运行
\u test
,并将其打印为
true


如果我删除对
/55652643/{document}
的权限,则不会到达
print
语句,相反,我会得到一个堆栈跟踪,该权限已被拒绝。

我们无法知道
data.documents.forEach((DocumentSnapshot doc)是什么{
是的,所以很难说出问题出在哪里。你能用一个硬编码的ID列表重现这个问题吗,如果是的话,更新你问题中的代码吗?我添加了我的firebase的两个屏幕截图。这对你有用吗?或者我应该硬编码列表吗?顺便说一句。我不认为问题与
data.documents.forEach有关((文档快照文档){
part。如果问题与循环无关,请在不使用循环的情况下复制问题并更新问题。如果问题与循环有关,请确保我们可以仅使用您提供的代码来复制问题。每次使用硬编码值都比任何动态值都重要。请参阅。好的,我更新了问题并删除了不必要的代码:)好的,这肯定与
var-keys=doc[“products”].keys.toList();
谢谢你的帮助!请注意,这正是我要求你在没有这些的情况下重现问题的原因。如果你运行了你共享的代码,你应该得到与我相同的结果。