Search code examples
androidiosflutterdartflutter-dependencies

How to get location every 10 sec using flutter


I am very new to flutter. I have to make an app that send the device location every 10 seconds, even if app is minimised and gets killed by the user. After that data i have to make a socket connection and a http post if(socket fails).

The app should must work with both Android and IOS. Is it possible to do in flutter?


Solution

  • background locator 2: https://pub.dev/packages/background_locator_2 Android works. The problem is that the time values are slightly random The value is delivered well within 10 seconds when the app is closed. However, if the app is turned off for a long time, due to the nature of Android, it is forcibly switched to sleep mode, so the return value is slightly random.

    iPhone works fine

    background_geolocation works well instead of being paid https://pub.dev/packages/flutter_background_geolocation