Locus class

Main class for interacting with background geolocation services.

This class serves as a facade for the core Locus modules.

v2.0 Service API

Access organized services via static getters:

// Location operations
await Locus.location.getCurrentPosition();
Locus.location.stream.listen((loc) => print(loc));

// Geofencing
await Locus.geofencing.add(geofence);

// Privacy zones
await Locus.privacy.add(zone);

// Trip tracking
await Locus.trips.start(config);

// Data sync
await Locus.sync.now();

// Battery optimization
await Locus.battery.estimateRunway();

Constructors

Locus()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

battery BatteryService
Battery service for power management and adaptive tracking.
final
currentTrackingProfile TrackingProfile?
no setter
dataSync SyncService
Sync service for data synchronization and queue management.
final
errorRecoveryManager ErrorRecoveryManager?
no setter
errorStream Stream<LocusError>?
no setter
events Stream<GeolocationEvent>
Stream of all geolocation events.
no setter
geofencing GeofenceService
Geofencing service for circular, polygon geofences and workflows.
final
instance LocusInterface
Current Locus implementation (method-channel or mock).
no setter
isForeground bool
no setter
isSignificantChangeMonitoringActive bool
no setter
location LocationService
Location service for getting positions, tracking, and history.
final
privacy PrivacyService
Privacy service for managing privacy zones.
final
significantChangeStream Stream<SignificantChangeEvent>?
no setter
spoofDetectionConfig SpoofDetectionConfig?
no setter
trips TripService
Trip service for tracking journeys.
final

Static Methods

analyzeForSpoofing(Location location, {bool? isMockProvider}) SpoofDetectionEvent?
applyRemoteCommand(RemoteCommand command) Future<bool>
clearHeadersCallback() → void
Clears the dynamic headers callback.
clearSyncBodyBuilder() → void
Clears the sync body builder callback.
clearTrackingProfiles() → void
destroy() Future<void>
Destroys the SDK instance, cleaning up all resources and static state.
evaluateSyncPolicy({required SyncPolicy policy}) Future<SyncDecision>
getDiagnostics() Future<DiagnosticsSnapshot>
getLog() Future<List<LogEntry>>
Gets structured log entries.
getState() Future<GeolocationState>
Gets the current state of the service.
handleError(LocusError error) Future<RecoveryAction>
isInActiveGeofence() Future<bool>
isTracking() Future<bool>
locationAnomalies({LocationAnomalyConfig config = const LocationAnomalyConfig()}) Stream<LocationAnomaly>
Stream of detected location anomalies.
locationQuality({LocationQualityConfig config = const LocationQualityConfig()}) Stream<LocationQuality>
Stream of location quality assessments.
onLocationAnomaly(void callback(LocationAnomaly anomaly), {LocationAnomalyConfig config = const LocationAnomalyConfig(), Function? onError}) StreamSubscription<LocationAnomaly>
onLocationQuality(void callback(LocationQuality quality), {LocationQualityConfig config = const LocationQualityConfig(), Function? onError}) StreamSubscription<LocationQuality>
ready(Config config, {bool skipValidation = false}) Future<GeolocationState>
Initializes the plugin with the given configuration.
recordBenchmarkLocationUpdate({double? accuracy}) → void
recordBenchmarkSync() → void
refreshHeaders() Future<void>
Manually triggers a header update.
registerHeadlessSyncBodyBuilder(Future<JsonMap> builder(SyncBodyContext context)) Future<bool>
Registers a headless-compatible sync body builder.
registerHeadlessTask(HeadlessEventCallback callback) Future<bool>
Registers a headless task callback.
requestPermission() Future<bool>
Requests all required permissions.
reset(Config config) Future<void>
Resets configuration to defaults, then applies the given config.
setConfig(Config config) Future<void>
Updates the configuration.
setErrorHandler(ErrorRecoveryConfig config) → void
setHeadersCallback(Future<Map<String, String>> callback()?) → void
Sets a callback to provide dynamic HTTP headers.
setMockInstance(LocusInterface mock) → void
Overrides the Locus implementation (useful for tests).
setSpoofDetection(SpoofDetectionConfig config) Future<void>
setSyncBodyBuilder(SyncBodyBuilder? builder) → void
Sets a callback to build custom HTTP sync body.
setTrackingProfile(TrackingProfile profile) Future<void>
setTrackingProfiles(Map<TrackingProfile, Config> profiles, {TrackingProfile? initialProfile, List<TrackingProfileRule> rules = const [], bool enableAutomation = false}) Future<void>
start() Future<GeolocationState>
Starts the background geolocation service.
startBackgroundTask() Future<int>
Starts a background task and returns its ID.
startBatteryBenchmark() Future<void>
startLifecycleObserving() → void
startSchedule() Future<bool>
Starts the schedule.
startSignificantChangeMonitoring([SignificantChangeConfig config = const SignificantChangeConfig()]) Future<void>
startTrackingAutomation() → void
stop() Future<GeolocationState>
Stops the background geolocation service.
stopBackgroundTask(int taskId) Future<void>
Stops a background task by ID.
stopBatteryBenchmark() Future<BenchmarkResult?>
stopLifecycleObserving() → void
stopSchedule() Future<bool>
Stops the schedule.
stopSignificantChangeMonitoring() Future<void>
stopTrackingAutomation() → void