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( );
} );
}