Background Location - Flutter

Viewed 4164

I have developed an application in flutter to capture the coordinates. code below is capturing coordinates correctly but the problem is, it is not working when the application is closed. I need to capture the location even the app is closed.Any help will be appreciated

@override
void initState() 
{
 super.initState( );
 BackgroundLocation.startLocationService( );
 BackgroundLocation.getLocationUpdates( (location) async {
  setState( () {
    debugPrint(globals.sUserCode);
    debugPrint(globals.sActiveTripCode);
    this.latitude = location.latitude.toString( );
    this.longitude = location.longitude.toString( );
    this.accuracy = location.accuracy.toString( );
    this.altitude = location.altitude.toString( );
    this.bearing = location.bearing.toString( );
    this.speed = location.speed.toString( );
    this.time =
        DateTime.fromMillisecondsSinceEpoch( location.time.toInt( ) )
            .toString( );
  } );
 }
3 Answers

I used such a package in the project. But the package has a certain limitation. Paid for extra use. We tried all the ways you did. But it didn't happen. Either you have to write from scratch by ios and android. otherwise, you may have no other choice. We had no other choice but to buy this package because our time was limited. And it works just fine.

You can also consider this plugin which has a pretty generous free tier and additional geo APIs and tracking functionality included.

Related