Config class

Configuration API.

The Config class defines all SDK options, grouped into compound configuration objects:

Instances of Config are consumed by BackgroundGeolocation.ready and BackgroundGeolocation.setConfig.

Example

import 'package:flutter_background_geolocation/flutter_background_geolocation.dart' as bg;

void main() async {
  // Configure the SDK with compound configuration objects.
  bg.Config config = bg.Config(
    geolocation: bg.GeoConfig(
      desiredAccuracy: bg.DesiredAccuracy.high,
      distanceFilter: 20.0,
      stopTimeout: 5,
      stationaryRadius: 150,
    ),
    activity: bg.ActivityConfig(
      activityRecognitionInterval: 10000,
      minimumActivityRecognitionConfidence: 75,
      disableStopDetection: false,
      motionTriggerDelay: 30000,
    ),
    http: bg.HttpConfig(
      url: 'https://my.server.com/api/locations',
      method: 'POST',
      autoSync: true,
      headers: {
        'Authorization': 'Bearer secret-token'
      },
      params: {
        'user_id': 123
      },
    ),
    persistence: bg.PersistenceConfig(
      persistMode: bg.PersistMode.all,
      maxDaysToPersist: 14,
      extras: {'appVersion': '1.0.0'},
    ),
    app: bg.AppConfig(
      stopOnTerminate: false,
      startOnBoot: true,
      enableHeadless: true,
      heartbeatInterval: 60,
    ),
    logger: bg.LoggerConfig(
      debug: true,
      logLevel: bg.LogLevel.verbose,
      logMaxDays: 3,
    ),
  );

  // Apply the configuration.
  bg.BackgroundGeolocation.ready(config).then((bg.State state) {
    print('[ready] BackgroundGeolocation is configured and ready to use');

    if (!state.enabled) {
      bg.BackgroundGeolocation.start();
    }
  });

  // To modify configuration after initialization, use [setConfig].
  bg.BackgroundGeolocation.setConfig(bg.Config(
    http: bg.HttpConfig(
      headers: {
        'Authorization': 'Bearer new-token'
      }
    ),
    logger: bg.LoggerConfig(
      logLevel: bg.Config.LOG_LEVEL_INFO
    ),
  )).then((bg.State state) {
    bg.BackgroundGeolocation.sync();
  });
}
Implementers

Constructors

Config({GeoConfig? geolocation, AppConfig? app, HttpConfig? http, PersistenceConfig? persistence, LoggerConfig? logger, ActivityConfig? activity, Authorization? authorization, int? desiredAccuracy, double? distanceFilter, double? stationaryRadius, int? locationTimeout, bool? disableElasticity, double? elasticityMultiplier, int? stopAfterElapsedMinutes, int? geofenceProximityRadius, int? maxMonitoredGeofences, bool? geofenceInitialTriggerEntry, double? desiredOdometerAccuracy, bool? useSignificantChangesOnly, String? locationAuthorizationRequest, bool? isMoving, int? stopTimeout, int? activityRecognitionInterval, int? minimumActivityRecognitionConfidence, bool? disableStopDetection, bool? stopOnStationary, String? url, int? persistMode, String? method, String? httpRootProperty, Map<String, dynamic>? params, Map<String, dynamic>? headers, Map<String, dynamic>? extras, bool? autoSync, bool? disableAutoSyncOnCellular, bool? disableProviderChangeRecord, int? autoSyncThreshold, bool? batchSync, int? maxBatchSize, String? locationTemplate, String? geofenceTemplate, int? maxDaysToPersist, int? maxRecordsToPersist, String? locationsOrderDirection, int? httpTimeout, bool? stopOnTerminate, bool? startOnBoot, int? heartbeatInterval, List<String>? schedule, bool? scheduleUseAlarmManager, bool? debug, int? logLevel, int? logMaxDays, bool? reset, bool? pausesLocationUpdatesAutomatically, Map<String, dynamic>? locationAuthorizationAlert, bool? disableLocationAuthorizationAlert, bool? showsBackgroundLocationIndicator, int? activityType, int? stopDetectionDelay, bool? disableMotionActivityUpdates, bool? preventSuspend, int? locationUpdateInterval, int? fastestLocationUpdateInterval, int? deferTime, bool? allowIdenticalLocations, bool? enableTimestampMeta, int? speedJumpFilter, bool? geofenceModeHighAccuracy, String? triggerActivities, int? motionTriggerDelay, bool? enableHeadless, bool? foregroundService, Notification? notification, PermissionRationale? backgroundPermissionRationale, TransistorAuthorizationToken? transistorAuthorizationToken})

Properties

activity → ActivityConfig?
Activity Recognition Configuration.
final
activityRecognitionInterval ↔ int?
Deprecated: Use ActivityConfig.activityRecognitionInterval via Config.activity.
getter/setter pair
activityType ↔ int?
Deprecated: Use GeoConfig.activityType via Config.geolocation.
getter/setter pair
allowIdenticalLocations ↔ bool?
Deprecated: Use GeoConfig.allowIdenticalLocations via Config.geolocation.
getter/setter pair
app → AppConfig?
Application & lifecycle configuration.
final
authorization ↔ Authorization?
Authorization Configuration
getter/setter pair
autoSync ↔ bool?
Deprecated: Use HttpConfig.autoSync via Config.http.
getter/setter pair
autoSyncThreshold ↔ int?
Deprecated: Use HttpConfig.autoSyncThreshold via Config.http.
getter/setter pair
backgroundPermissionRationale ↔ PermissionRationale?
Deprecated: Use AppConfig.backgroundPermissionRationale via Config.app.
getter/setter pair
batchSync ↔ bool?
Deprecated: Use HttpConfig.batchSync via Config.http.
getter/setter pair
debug ↔ bool?
Logger Config Deprecated: Use LoggerConfig.debug via Config.logger.
getter/setter pair
deferTime ↔ int?
Deprecated: Use GeoConfig.deferTime via Config.geolocation.
getter/setter pair
desiredAccuracy ↔ int?
Geolocation Config
getter/setter pair
desiredOdometerAccuracy ↔ double?
Deprecated: Use LocationFilter.odometerAccuracyThreshold via Config.geolocation.filter.
getter/setter pair
disableAutoSyncOnCellular ↔ bool?
Deprecated: Use HttpConfig.disableAutoSyncOnCellular via Config.http.
getter/setter pair
disableElasticity ↔ bool?
Deprecated: Use GeoConfig.disableElasticity via Config.geolocation.
getter/setter pair
disableLocationAuthorizationAlert ↔ bool?
Deprecated: Use GeoConfig.disableLocationAuthorizationAlert via Config.geolocation.
getter/setter pair
disableMotionActivityUpdates ↔ bool?
Deprecated: Use ActivityConfig.disableMotionActivityUpdates via Config.activity.
getter/setter pair
disableProviderChangeRecord ↔ bool?
Deprecated: Use PersistenceConfig.disableProviderChangeRecord via Config.persistence.
getter/setter pair
disableStopDetection ↔ bool?
Deprecated: Use ActivityConfig.disableStopDetection via Config.activity.
getter/setter pair
distanceFilter ↔ double?
Deprecated: Use GeoConfig.distanceFilter via Config.geolocation.
getter/setter pair
elasticityMultiplier ↔ double?
Deprecated: Use GeoConfig.elasticityMultiplier via Config.geolocation.
getter/setter pair
enableHeadless ↔ bool?
Deprecated: Use AppConfig.enableHeadless via Config.app.
getter/setter pair
enableTimestampMeta ↔ bool?
Deprecated: Use GeoConfig.enableTimestampMeta via Config.geolocation.
getter/setter pair
extras ↔ Map<String, dynamic>?
Deprecated: Use PersistenceConfig.extras via Config.persistence.
getter/setter pair
fastestLocationUpdateInterval ↔ int?
Deprecated: Use GeoConfig.fastestLocationUpdateInterval via Config.geolocation.
getter/setter pair
foregroundService ↔ bool?
Deprecated: No longer used; always true.
getter/setter pair
geofenceInitialTriggerEntry ↔ bool?
Deprecated: Use GeoConfig.geofenceInitialTriggerEntry via Config.geolocation.
getter/setter pair
geofenceModeHighAccuracy ↔ bool?
Deprecated: Use GeoConfig.geofenceModeHighAccuracy via Config.geolocation.
getter/setter pair
geofenceProximityRadius ↔ int?
Deprecated: Use GeoConfig.geofenceProximityRadius via Config.geolocation.
getter/setter pair
geofenceTemplate ↔ String?
Deprecated: Use PersistenceConfig.geofenceTemplate via Config.persistence.
getter/setter pair
geolocation → GeoConfig?
Geolocation Configuration.
final
hashCode → int
The hash code for this object.
no setterinherited
headers ↔ Map<String, dynamic>?
Deprecated: Use HttpConfig.headers via Config.http.
getter/setter pair
heartbeatInterval ↔ int?
Deprecated: Use AppConfig.heartbeatInterval via Config.app.
getter/setter pair
http → HttpConfig?
HTTP / Networking Configuration
final
httpRootProperty ↔ String?
Deprecated: Use HttpConfig.rootProperty via Config.http.
getter/setter pair
httpTimeout ↔ int?
Deprecated: Use HttpConfig.timeout via Config.http.
getter/setter pair
isMoving ↔ bool?
Activity-recognition Config Configure the SDK's initial state to tracking with location-services ON.
getter/setter pair
locationAuthorizationAlert ↔ Map<String, dynamic>?
Deprecated: Use GeoConfig.locationAuthorizationAlert via Config.geolocation.
getter/setter pair
locationAuthorizationRequest ↔ String?
Deprecated: Use GeoConfig.locationAuthorizationRequest via Config.geolocation.
getter/setter pair
locationsOrderDirection ↔ String?
Deprecated: Use PersistenceConfig.locationsOrderDirection via Config.persistence.
getter/setter pair
locationTemplate ↔ String?
Deprecated: Use PersistenceConfig.locationTemplate via Config.persistence.
getter/setter pair
locationTimeout ↔ int?
Deprecated: Use GeoConfig.locationTimeout via Config.geolocation.
getter/setter pair
locationUpdateInterval ↔ int?
Deprecated: Use GeoConfig.locationUpdateInterval via Config.geolocation.
getter/setter pair
logger → LoggerConfig?
Logging / Diagnostics Configuration
final
logLevel ↔ int?
Deprecated: Use LoggerConfig.logLevel via Config.logger.
getter/setter pair
logMaxDays ↔ int?
Deprecated: Use LoggerConfig.logMaxDays via Config.logger.
getter/setter pair
maxBatchSize ↔ int?
Deprecated: Use HttpConfig.maxBatchSize via Config.http.
getter/setter pair
maxDaysToPersist ↔ int?
Deprecated: Use PersistenceConfig.maxDaysToPersist via Config.persistence.
getter/setter pair
maxMonitoredGeofences ↔ int?
Deprecated: Use GeoConfig.maxMonitoredGeofences via Config.geolocation.
getter/setter pair
maxRecordsToPersist ↔ int?
Deprecated: Use PersistenceConfig.maxRecordsToPersist via Config.persistence.
getter/setter pair
method ↔ String?
Deprecated: Use HttpConfig.method via Config.http.
getter/setter pair
minimumActivityRecognitionConfidence ↔ int?
Deprecated: Use ActivityConfig.minimumActivityRecognitionConfidence via Config.activity.
getter/setter pair
motionTriggerDelay ↔ int?
Deprecated: Use ActivityConfig.motionTriggerDelay via Config.activity.
getter/setter pair
notification ↔ Notification?
Deprecated: Use AppConfig.notification via Config.app.
getter/setter pair
params ↔ Map<String, dynamic>?
Deprecated: Use HttpConfig.params via Config.http.
getter/setter pair
pausesLocationUpdatesAutomatically ↔ bool?
Deprecated: Use GeoConfig.pausesLocationUpdatesAutomatically via Config.geolocation.
getter/setter pair
persistence → PersistenceConfig?
Persistence / Storage Configuration
final
persistMode ↔ int?
Persistence Config Deprecated: Use PersistenceConfig.persistMode via Config.persistence.
getter/setter pair
preventSuspend ↔ bool?
Deprecated: Use AppConfig.preventSuspend via Config.app.
getter/setter pair
reset ↔ bool?
Determines whether to reset the existing Config to defaults before appying new config (default true)
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
schedule ↔ List<String>?
Deprecated: Use AppConfig.schedule via Config.app.
getter/setter pair
scheduleUseAlarmManager ↔ bool?
Deprecated: Use AppConfig.scheduleUseAlarmManager via Config.app.
getter/setter pair
showsBackgroundLocationIndicator ↔ bool?
Deprecated: Use GeoConfig.showsBackgroundLocationIndicator via Config.geolocation.
getter/setter pair
speedJumpFilter ↔ int?
Deprecated: Use GeoConfig.filter settings via Config.geolocation.
getter/setter pair
startOnBoot ↔ bool?
Deprecated: Use AppConfig.startOnBoot via Config.app.
getter/setter pair
stationaryRadius ↔ double?
Deprecated: Use GeoConfig.stationaryRadius via Config.geolocation.
getter/setter pair
stopAfterElapsedMinutes ↔ int?
Deprecated: Use GeoConfig.stopAfterElapsedMinutes via Config.geolocation.
getter/setter pair
stopDetectionDelay ↔ int?
Deprecated: Use ActivityConfig.stopDetectionDelay via Config.activity.
getter/setter pair
stopOnStationary ↔ bool?
Deprecated: Use ActivityConfig.stopOnStationary via Config.activity.
getter/setter pair
stopOnTerminate ↔ bool?
Application Config Deprecated: Use AppConfig.stopOnTerminate via Config.app.
getter/setter pair
stopTimeout ↔ int?
Deprecated: Use GeoConfig.stopTimeout via Config.geolocation.
getter/setter pair
transistorAuthorizationToken ↔ TransistorAuthorizationToken?
Convenience option to automatically configures the SDK to upload locations to the Transistor Software demo server at http://tracker.transistorsoft.com (or your own local instance of background-geolocation-console)
getter/setter pair
triggerActivities ↔ String?
Deprecated: Use ActivityConfig.triggerActivities via Config.activity.
getter/setter pair
url ↔ String?
HTTP Config Deprecated: Use HttpConfig.url via Config.http.
getter/setter pair
useSignificantChangesOnly ↔ bool?
Deprecated: Use GeoConfig.useSignificantChangesOnly via Config.geolocation.
getter/setter pair

Methods

compoundToMap() → Map<String, dynamic>
Returns only the compound config groups as a Map suitable for marshalling.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
set(String key, dynamic value) → Config
toMap() → Map?
toString() → String
A string representation of this object.
inherited

Operators

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

Static Properties

deviceParams → Future<Map<String, dynamic>>
@deprecated: Use transistorAuthorizationToken
no setter