【问题标题】:Geoflutter returns duplicate snapsGeoflutter 返回重复的快照
【发布时间】:2019-10-25 08:15:57
【问题描述】:

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

我遇到了同样的问题,我找到了错误并修复了它。这是因为 lib 未处理的边缘情况导致重复查询。

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

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

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

干杯?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-05
    • 2021-07-03
    • 2017-03-24
    • 2020-10-12
    • 1970-01-01
    • 1970-01-01
    • 2010-12-31
    • 1970-01-01
    相关资源
    最近更新 更多