Geoflutter返回重复的快照

问题描述 投票:0回答:1

由于某种原因,此代码(使用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

flutter dart google-cloud-firestore geofire
1个回答
0
投票

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

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

要修复它(直到this issue被lib维护程序修补),您可以更新您的pubspec.yaml

文件以获取我的固定分支:
geoflutterfire:
    git:
      url: git://github.com/Thibault2ss/GeoFlutterFire
      ref: fix-duplicate-results-on-large-radius

干杯👍

© www.soinside.com 2019 - 2024. All rights reserved.