GeoConfig class
Geolocation Configuration.
The GeoConfig object defines all geolocation-related options for the BackgroundGeolocation SDK. These parameters control how often the SDK acquires locations, how accurately, how long tracking persists when stationary, and how it handles platform-specific permissions, filtering, and elasticity.
Overviewd
GeoConfig is consumed via the Config.geolocation property when calling BackgroundGeolocation.ready or BackgroundGeolocation.setConfig.
| Category | Description |
|---|---|
| Accuracy | Controls desired location precision GeoConfig.desiredAccuracy, filtering distance GeoConfig.distanceFilter, and timing intervals GeoConfig.locationUpdateInterval, GeoConfig.fastestLocationUpdateInterval |
| Elasticity | Adjusts responsiveness to motion and idling via GeoConfig.disableElasticity, GeoConfig.elasticityMultiplier, and GeoConfig.stopTimeout. |
| Permissions | Manages platform authorization GeoConfig.locationAuthorizationRequest, alerts GeoConfig.locationAuthorizationAlert / GeoConfig.disableLocationAuthorizationAlert |
| Geofencing | Configures geofence monitoring behavior and entry triggers. |
| Filtering | Provides fine-grained control over the SDK’s noise-reduction filter via GeoConfig.filter. |
Example
import 'package:flutter_background_geolocation/flutter_background_geolocation.dart' as bg;
void main() async {
bg.Config config = bg.Config(
geolocation: bg.GeoConfig(
// High-precision GPS
desiredAccuracy: bg.DesiredAccuracy.high,
// Move at least 50 meters before recording next location.
distanceFilter: 50.0,
// Consider the device stationary after 5 minutes of no motion.
stopTimeout: 5,
// Automatically stop tracking after 120 minutes of continuous operation.
stopAfterElapsedMinutes: 120,
// Show the blue location indicator when tracking in the background (iOS).
showsBackgroundLocationIndicator: true,
// Customize filtering and denoising of incoming locations.
filter: bg.LocationFilter(
policy: bg.LocationFilterPolicy.adjust,
maxImpliedSpeed: 60,
odometerAccuracyThreshold: 20,
trackingAccuracyThreshold: 100
),
// Configure geofence-related behavior.
geofenceProximityRadius: 1000,
geofenceInitialTriggerEntry: true,
geofenceModeHighAccuracy: true,
// Handle iOS authorization and alerts.
locationAuthorizationRequest: 'Always',
disableLocationAuthorizationAlert: false,
locationAuthorizationAlert: {
'titleWhenNotEnabled': 'Location Required',
'message': 'Enable location access for full functionality.',
'cancelButton': 'Cancel',
'settingsButton': 'Settings'
},
),///
// Additional compound config groups may be defined here:
http: bg.HttpConfig(
url: 'https://example.com/api/locations',
autoSync: true,
batchSync: true,
maxBatchSize: 10,
method: 'POST',
params: {
'user_id': 1234,
'trip_id': 5678
},
headers: {
'X-FOO': 'bar',
},
),
app: bg.AppConfig(
stopOnTerminate: false,
startOnBoot: true
),
logging: bg.LoggerConfig(
debug: true,
logLevel: bg.LoggerConfig.LOG_LEVEL_VERBOSE
)
);
// Apply configuration
await bg.BackgroundGeolocation.ready(config);
}
Migration from legacy flat Config
Previously, geolocation options were defined directly in the root Config object:
// Legacy (flat)
Config(
desiredAccuracy: Config.DESIRED_ACCURACY_HIGH,
distanceFilter: 10.0,
stopTimeout: 5,
stationaryRadius: 150.0,
locationTimeout: 60,
);
These options are now grouped under the GeoConfig compound object, accessed via Config.geolocation:
// New (compound)
Config(
geolocation: GeoConfig(
desiredAccuracy: DesiredAccuracy.high,
distanceFilter: 10.0,
stopTimeout: 5,
stationaryRadius: 150.0,
locationTimeout: 60,
),
);
Legacy flat fields are still supported for backward compatibility, but they are now marked @Deprecated. Going forward, prefer using Config.geolocation for all location-related options to improve organization and clarity.
See also
- LocationFilter for location denoising options.
- AppConfig for lifecycle and startup behavior.
Constructors
-
GeoConfig({double? distanceFilter, DesiredAccuracy? desiredAccuracy, int? locationUpdateInterval, int? fastestLocationUpdateInterval, int? locationTimeout, int? deferTime, bool? disableElasticity, double? elasticityMultiplier, bool? allowIdenticalLocations, bool? enableTimestampMeta, bool? useSignificantChangesOnly, bool? disableLocationAuthorizationAlert, String? locationAuthorizationRequest, int? stationaryRadius, int? stopTimeout, int? stopAfterElapsedMinutes, int? geofenceProximityRadius, bool? geofenceInitialTriggerEntry, bool? geofenceModeHighAccuracy, LocationFilter? filter, bool? pausesLocationUpdatesAutomatically, bool? showsBackgroundLocationIndicator, ActivityType? activityType, Map<
String, dynamic> ? locationAuthorizationAlert, int? maxMonitoredGeofences}) -
const
-
GeoConfig.fromMap(Map<
String, dynamic> m) -
factory
Properties
- activityType → ActivityType?
-
[iOS only]Presumably, this affects iOS stop-detect algorithm. Apple is vague about what exactly this option does.final - allowIdenticalLocations → bool?
-
[Android only]Allow recording locations which are duplicates of the previous.final - deferTime → int?
-
[Android only]Sets the maximum wait time in milliseconds for location updates.final - desiredAccuracy → DesiredAccuracy?
-
Specify the desired-accuracy of the geolocation system.
final
- disableElasticity → bool?
-
Disable automatic, speed-based GeoConfig.distanceFilter scaling.
final
- disableLocationAuthorizationAlert → bool?
-
Disables automatic authorization alert when SDK detects the user has disabled location authorization.
final
- distanceFilter → double?
-
The minimum distance (measured in meters) a device must move horizontally before an update event is generated.
final
- elasticityMultiplier → double?
-
Controls the scale of automatic speed-based GeoConfig.distanceFilter elasticity.
final
- enableTimestampMeta → bool?
-
Enable extra timestamp meta data to be appended to each recorded location, including system-time.
final
- fastestLocationUpdateInterval → int?
-
[Android only]Explicitly set the fastest interval for location updates, in milliseconds.final - filter → LocationFilter?
-
Defines how raw GPS location samples are filtered, denoised, and smoothed before being
recorded or used for odometer calculations.
final
- geofenceInitialTriggerEntry → bool?
-
When a device is already within a just-created geofence, fire the enter transition immediately.
final
- geofenceModeHighAccuracy → bool?
-
[Android only]Enable high-accuracy for geofence-only mode (See BackgroundGeolocation.startGeofences).final - geofenceProximityRadius → int?
-
The radius around current location to query for geofences to activate monitoring upon.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
locationAuthorizationAlert
→ Map<
String, dynamic> ? -
[iOS only]Controls the text-elements of the SDK's location-authorization dialog.final - locationAuthorizationRequest → String?
-
Defines the desired location-authorization request you wish for the user to authorize:
final
- locationTimeout → int?
-
The default timeout in seconds when requesting a location before the SDK gives up and fires a LocationError.
final
- locationUpdateInterval → int?
-
[Android only]Set the desired interval for active location updates, in milliseconds.final - maxMonitoredGeofences → int?
-
The maximum number of geofences to monitor at-a-time, overriding the platform default (iOS: 20; Android 100).
NOTE: This option is for specialized use-cases where you wish to monitor LESS THAN the platform maximum. This option should generally not be used.
final
- pausesLocationUpdatesAutomatically → bool?
-
[iOS only]Configure iOS location API to never automatically turn off.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showsBackgroundLocationIndicator → bool?
-
[iOS Only]A Boolean indicating whether the status bar changes its appearance when an app uses location services in the background.final - stationaryRadius → int?
-
The minimum distance the device must move beyond the stationary location for aggressive background-tracking to engage.
final
- stopAfterElapsedMinutes → int?
-
Automatically BackgroundGeolocation.stop tracking after x minutes.
final
- stopTimeout → int?
-
Minutes to wait in moving state with no movement before considering the device stationary.
final
- useSignificantChangesOnly → bool?
-
Set
truein order to disable constant background-tracking. Locations will be recorded only periodically.final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toMap(
) → Map< String, dynamic> -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited