I'm trying to send the latest location update received from carp_background_location to Firestore. The callback doesn't get excuted when the app is terminated on Android. I haven't tried if it works on iOS yet.

I'm following this example provided by the package: example

What I want is to use this callback to send location to Firestore:

void onData(LocationDto dto) {
    // print(dtoToString(dto));
    setState(() {
      lastLocation = dto;
      lastTimeLocation = DateTime.now();


this works fine in the foreground or the background but not when the app is terminated.

I'd really appreciate a solution to the problem or guidance on how to make it work.

Solution 1: M.M.Hasibuzzaman

https://pub.dev/packages/background_fetch take a look at this, this should solve your issue