1

I have to increase the call time of setLocation() because I spend so much on google APIs (in 2 days 100€ and I am only testing the app). I have tried timers and debounce functions but have not yet been able to come up with a solution.

updateDriversLocationAtRealTime()
  {
      streamSubscriptionPosition = Geolocator.getPositionStream()
          .listen((Position position)
      {
          driverCurrentPosition = position;

          if(isDriverActive == true)
          {
              Geofire.setLocation(
                currentFirebaseUser!.uid,
                driverCurrentPosition!.latitude,
                driverCurrentPosition!.longitude
              );
          }

          LatLng latLng = LatLng(
              driverCurrentPosition!.latitude,
              driverCurrentPosition!.longitude,
          );

          newGoogleMapController!.animateCamera(CameraUpdate.newLatLng(latLng));
      });
  }
Simone
  • 83
  • 6
  • 1
    use https://pub.dev/documentation/stream_transform/latest/stream_transform/RateLimit/throttle.html or https://pub.dev/documentation/stream_transform/latest/stream_transform/RateLimit/audit.html – pskink Jan 16 '23 at 15:10
  • Correct: I used the throttle method like this : streamSubscriptionPosition = Geolocator.getPositionStream() .throttle(Duration(milliseconds: 1000)) .listen((Position position) – Simone Jan 16 '23 at 18:01

0 Answers0