LiveLocationService class
Main service class for live background location tracking with server sync.
LiveLocationService provides a high-level API for continuous location tracking that works even when the app is terminated. It includes:
- Automatic server synchronization
- Offline support with local storage
- Retry logic for failed syncs
- Battery-efficient tracking
Example usage:
final service = LiveLocationService();
// Configure the service
final config = LiveLocationConfig(
apiBaseUrl: 'https://api.example.com',
apiEndpoint: '/api/v1/locations',
);
// Start tracking
await service.start(
config: config,
onLocation: (location) {
print('Location: ${location.latitude}, ${location.longitude}');
},
onSync: (count) {
print('Synced $count locations');
},
onError: (error) {
print('Error: $error');
},
);
// Check status
bool isRunning = await service.isTracking();
// Stop tracking
await service.stop();
Constructors
- LiveLocationService()
-
factory
Properties
- config → LiveLocationConfig?
-
Get current configuration
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
initialize(
) → Future< void> - Initialize the service
-
isTracking(
) → Future< bool> - Check if location tracking is currently active
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
start(
{required LiveLocationConfig config, required void onLocation(LocationDto), void onError(String error)?}) → Future< void> - Start live location tracking with server sync
-
stop(
) → Future< void> - Stop location tracking
-
toString(
) → String -
A string representation of this object.
inherited
-
updateNotification(
{String? title, String? message, String? bigMessage}) → Future< void> - Update the notification text (Android only)
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited