rekabhq / background_locator

A Flutter plugin for updating location in background.
MIT License
287 stars 321 forks source link

How can I send data from location callback to controller? #347

Closed kotran88 closed 1 year ago

kotran88 commented 1 year ago

on location_service_repository.dart


  Future<void> callback(LocationDto locationDto) async {
    try {
      print('$_count location in dart: ${locationDto.toString()}');

      final SendPort? send = IsolateNameServer.lookupPortByName(isolateName);
      send?.send(locationDto);
      _count++;
    } catch (e) {
      // code for handling exception
      print("error  : $e");
    }
  }

and receiving controller...

 port.listen(
      (dynamic data) async {
        print("enter inside listen.....");
        print(data);
        await updateUI(data);
      },
    );

it works very well when app is foreground or background from callback, I send then on controller, it received well.

but the problem comes when app is killed. it dosen't reach to port.listen inside.

how can I pass location data from callback to controller even when app is killed.

hpsolver commented 1 year ago

@kotran88 Did you get solution for above problem ?