Search code examples
flutterdartgeolocationgeocodingbackground-process

How to auto update someone location (latitude and longitude) in flutter


If a user opens my app, am able to get his latitude, longitude and address using Geolocator and Geocoder and when someone search for people nearby i can calculate the distance using his last known updated location and show to someone else that he is nearby

double distanceInMeters = Geolocator.distanceBetween(52.2165157, 6.9437819, 52.3546274, 4.8285838);

but what I want to do is, is there a way to automatically get his lat and long even when he isn't using the app because if he/she changes location, his last location where he last opened the app will still be showing and this might cause some confusion. Please Is there a way to do this maybe from background.


Solution

  • You can have a look to this differents libs :

    https://pub.dev/packages/background_location

    https://pub.dev/packages/flutter_background_geolocation

    https://github.com/icapps/flutter-background-location-tracker