Geoflutter返回重复的快照

时间:2019-10-25 08:15:57

标签: flutter dart google-cloud-firestore geofire

出于某种原因,此代码(使用GeoFlutterFire)向我返回了Firestore数据库中每个DocumentSnapshot的副本:

Stream<List<DocumentSnapshot>> stream = await geo
        .collection(collectionRef: firestore.collection(structuresCollection))
        .within(center: center, radius: radius, field: field);

stream.listen((List<DocumentSnapshot> docList) async {
      placeModel = await updateList(docList);
      _placeFetcher.sink.add(placeModel);
      print('Place model: ${placeModel}');
    });

我已经尝试调试它,并且复制从这里开始,但这只是一个简单的查询,我真的不明白它的问题所在

如您所见,长度为14,应该为7,每个快照都重复一次

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,我发现了该错误并进行了修复。这是因为lib无法处理一个极端情况,因此创建了重复查询。

对于较大的查询半径,当lib生成“邻居的地理位置”列表时,它实际上返回一个包含所有邻居 AND 原始(1个字符)geohash的列表,而不是仅返回邻居哈希。

要对其进行修复(直到this issue被lib维护者修补),您可以更新您的 pubspec.yaml 文件以获取我的固定分支:

geoflutterfire:
    git:
      url: git://github.com/Thibault2ss/GeoFlutterFire
      ref: fix-duplicate-results-on-large-radius

干杯?