Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter: Fetch Geo-location in the background

i need my app to send the current location over to an API in the background ,specifically when the app is closed. I found that there are restrictions as to how it can be implemented for IOS. Is there any solution in flutter to implement this for both platforms?

like image 230
Seby Joseph Avatar asked Jan 18 '19 15:01

Seby Joseph


People also ask

How do I fetch user location in background with Flutter?

Position userLocation = await geoLocator. getCurrentPosition(desiredAccuracy: LocationAccuracy. high); As you have guessed, this line will actually get the current position.

How do you get geo location on Flutter?

Get user's latitude and longitude To query the current location of the device, simply make a call to the getCurrentPosition() method. For example: import 'package:geolocator/geolocator. dart';Position position = await Geolocator.


1 Answers

So far i have found a plugin that works in the background - except is it not free.

flutter_background_geolocation 1.7.3

https://pub.dev/packages/flutter_background_geolocation

It does exactly what you would want - work in the background for both platforms, you can use it in development for free, but when you launch the app - you need to pay for it (Android platform).

like image 98
matshidis Avatar answered Nov 03 '22 08:11

matshidis