Config.fromMap constructor
Implementation
factory Config.fromMap(JsonMap map) {
return Config(
desiredAccuracy: _parseEnum(
map['desiredAccuracy'] as String?,
DesiredAccuracy.values,
),
distanceFilter: (map['distanceFilter'] as num?)?.toDouble(),
locationUpdateInterval: (map['locationUpdateInterval'] as num?)?.toInt(),
fastestLocationUpdateInterval:
(map['fastestLocationUpdateInterval'] as num?)?.toInt(),
activityRecognitionInterval:
(map['activityRecognitionInterval'] as num?)?.toInt(),
stopTimeout: (map['stopTimeout'] as num?)?.toInt(),
stopAfterElapsedMinutes:
(map['stopAfterElapsedMinutes'] as num?)?.toInt(),
stopDetectionDelay: (map['stopDetectionDelay'] as num?)?.toInt(),
motionTriggerDelay: (map['motionTriggerDelay'] as num?)?.toInt(),
minimumActivityRecognitionConfidence:
(map['minimumActivityRecognitionConfidence'] as num?)?.toInt(),
useSignificantChangesOnly: map['useSignificantChangesOnly'] as bool?,
allowIdenticalLocations: map['allowIdenticalLocations'] as bool?,
disableMotionActivityUpdates:
map['disableMotionActivityUpdates'] as bool?,
disableStopDetection: map['disableStopDetection'] as bool?,
disableProviderChangeRecord: map['disableProviderChangeRecord'] as bool?,
disableLocationAuthorizationAlert:
map['disableLocationAuthorizationAlert'] as bool?,
enableHeadless: map['enableHeadless'] as bool?,
startOnBoot: map['startOnBoot'] as bool?,
stopOnTerminate: map['stopOnTerminate'] as bool?,
foregroundService: map['foregroundService'] as bool?,
preventSuspend: map['preventSuspend'] as bool?,
pausesLocationUpdatesAutomatically:
map['pausesLocationUpdatesAutomatically'] as bool?,
showsBackgroundLocationIndicator:
map['showsBackgroundLocationIndicator'] as bool?,
stationaryRadius: (map['stationaryRadius'] as num?)?.toDouble(),
desiredOdometerAccuracy:
(map['desiredOdometerAccuracy'] as num?)?.toDouble(),
elasticityMultiplier: (map['elasticityMultiplier'] as num?)?.toDouble(),
speedJumpFilter: (map['speedJumpFilter'] as num?)?.toDouble(),
stopOnStationary: map['stopOnStationary'] as bool?,
geofenceModeHighAccuracy: map['geofenceModeHighAccuracy'] as bool?,
geofenceInitialTriggerEntry: map['geofenceInitialTriggerEntry'] as bool?,
geofenceProximityRadius:
(map['geofenceProximityRadius'] as num?)?.toInt(),
maxMonitoredGeofences: (map['maxMonitoredGeofences'] as num?)?.toInt(),
locationTimeout: (map['locationTimeout'] as num?)?.toInt(),
httpTimeout: (map['httpTimeout'] as num?)?.toInt(),
maxRetry: (map['maxRetry'] as num?)?.toInt(),
retryDelay: (map['retryDelay'] as num?)?.toInt(),
retryDelayMultiplier: (map['retryDelayMultiplier'] as num?)?.toDouble(),
maxRetryDelay: (map['maxRetryDelay'] as num?)?.toInt(),
bgTaskId: map['bgTaskId'] as String?,
url: map['url'] as String?,
method: map['method'] as String?,
headers: map['headers'] is Map
? Map<String, dynamic>.from(map['headers'] as Map)
: null,
params: map['params'] is Map
? Map<String, dynamic>.from(map['params'] as Map)
: null,
extras: map['extras'] is Map
? Map<String, dynamic>.from(map['extras'] as Map)
: null,
autoSync: map['autoSync'] as bool?,
batchSync: map['batchSync'] as bool?,
maxBatchSize: (map['maxBatchSize'] as num?)?.toInt(),
autoSyncThreshold: (map['autoSyncThreshold'] as num?)?.toInt(),
disableAutoSyncOnCellular: map['disableAutoSyncOnCellular'] as bool?,
queueMaxDays: (map['queueMaxDays'] as num?)?.toInt(),
queueMaxRecords: (map['queueMaxRecords'] as num?)?.toInt(),
idempotencyHeader: map['idempotencyHeader'] as String?,
persistMode: _parseEnum(
map['persistMode'] as String?,
PersistMode.values,
),
maxDaysToPersist: (map['maxDaysToPersist'] as num?)?.toInt(),
maxRecordsToPersist: (map['maxRecordsToPersist'] as num?)?.toInt(),
locationTemplate: map['locationTemplate'] as String?,
geofenceTemplate: map['geofenceTemplate'] as String?,
httpRootProperty: map['httpRootProperty'] as String?,
schedule: (map['schedule'] as List?)?.cast<String>(),
scheduleUseAlarmManager: map['scheduleUseAlarmManager'] as bool?,
forceReloadOnBoot: map['forceReloadOnBoot'] as bool?,
forceReloadOnLocationChange: map['forceReloadOnLocationChange'] as bool?,
forceReloadOnMotionChange: map['forceReloadOnMotionChange'] as bool?,
forceReloadOnGeofence: map['forceReloadOnGeofence'] as bool?,
forceReloadOnHeartbeat: map['forceReloadOnHeartbeat'] as bool?,
forceReloadOnSchedule: map['forceReloadOnSchedule'] as bool?,
enableTimestampMeta: map['enableTimestampMeta'] as bool?,
notification: map['notification'] is Map
? NotificationConfig.fromMap(
Map<String, dynamic>.from(map['notification'] as Map),
)
: null,
logLevel: _parseEnum(map['logLevel'] as String?, LogLevel.values),
logMaxDays: (map['logMaxDays'] as num?)?.toInt(),
heartbeatInterval: (map['heartbeatInterval'] as num?)?.toInt(),
backgroundPermissionRationale: map['backgroundPermissionRationale'] is Map
? PermissionRationale.fromMap(
Map<String, dynamic>.from(
map['backgroundPermissionRationale'] as Map),
)
: null,
triggerActivities: (map['triggerActivities'] as List?)
?.map((e) => ActivityType.values.firstWhere(
(v) => v.name == e,
orElse: () => ActivityType.unknown,
))
.toList(),
adaptiveTracking: map['adaptiveTracking'] != null
? AdaptiveTrackingConfig.fromMap(
Map<String, dynamic>.from(map['adaptiveTracking'] as Map))
: null,
lowBattery: map['lowBattery'] != null
? LowBatteryConfig.fromMap(
Map<String, dynamic>.from(map['lowBattery'] as Map))
: null,
spoofDetection: map['spoofDetection'] != null
? SpoofDetectionConfig.fromMap(
Map<String, dynamic>.from(map['spoofDetection'] as Map))
: null,
);
}