Flutter Geolocation 后台更新不一致

Flutter Geolocation background updates inconsistent

我有以下每 10 米获取一次用户位置的 StreamSubscription:

StreamSubscription < LocationResult > subscription = Geolocation.locationUpdates(
    accuracy: LocationAccuracy.best,
    displacementFilter: 10.0,
    inBackground: true,
  )
  .listen((result) {
    if (result.isSuccessful) {
      saveResult(result);
    } else {}
  });

然后调用 saveResult(result) 将结果保存在 firestore 中。当应用程序在前台时,一切都按预期工作,但当它进入后台时,它有时会继续保存几百米的结果,然后停止保存。但是,结果继续被缓冲,因为当应用程序重新获得焦点时,saveResult(result) 会重复执行,您可以在 firestore 中看到结果一个接一个地快速添加。有没有办法在后台使用应用程序更一致地更新结果?

我也面临这个问题,我开发了自己的后台位置更新插件,在这里,flutter_background_location。 android 没问题,但我不确定 iOS,因为我没有 mac。