Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter live tracking

I am new to flutter development, with android background, i am developing an app for live tracking with flutter using "location" third party api link : https://pub.dev/packages/location how ever in most devices the location stream stops when app is in background and the phone is not in use, after a certain time, i am unable to work around this issue have included this api as well but it wont launch the service again, link : https://pub.dev/packages/background_fetch but they dont seem to solve my problem, if anyone has worked with tracking on flutter application please do share.

Thanks

The result i am asking for. no matter the state of the phone location should be fetched and posted to server given the app is in background and the phone not in use.

Edit: 27-11-2020 As it turns out there was no solution and this is not related to flutter, but android in general. For people with this issue please read through DOZE MODE it was introduced in android 6.0 on-wards. The solution I did was to attain wake lock, and keep the screen on so to avoid doze mode but this is not the most optimized solution obviously.

like image 983
Shayan khan Avatar asked Jul 24 '26 20:07

Shayan khan


1 Answers

I solved background location service in Flutter by using platform-channel. I have combined android foreground service ( yes foreground, accessing GPS location in background does not allow for real-time.)

enter image description here

I have solved real-time background location flutter app for Android by using Platform Channel, Android Foreground Service. It's work perfectly whenever screen is ON or Off and you don't need to wakeup the screen the whole time to get location update.

Image Source : https://flutter.dev/

https://flutter.dev/docs/development/platform-integration/platform-channels

like image 161
Aung Ko Man Avatar answered Jul 26 '26 09:07

Aung Ko Man



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!