State constructor
State(
- Map data
Implementation
State(Map data)
:
// flatten compound state for backward compatibility
super(
geolocation: (data['geolocation'] is Map)
? GeoConfig.fromMap(_ensureStringKeyedMap(data['geolocation']))
: null,
app: (data['app'] is Map)
? AppConfig.fromMap(_ensureStringKeyedMap(data['app']))
: null,
http: (data['http'] is Map)
? HttpConfig.fromMap(_ensureStringKeyedMap(data['http']))
: null,
activity: (data['activity'] is Map)
? ActivityConfig.fromMap(
_ensureStringKeyedMap(data['activity']))
: null,
persistence: (data['persistence'] is Map)
? PersistenceConfig.fromMap(
_ensureStringKeyedMap(data['persistence']))
: null,
logger: (data['logger'] is Map)
? LoggerConfig.fromMap(_ensureStringKeyedMap(data['logger']))
: null,
desiredAccuracy:
_ensureInt((_flattenCompoundState(data))['desiredAccuracy']),
distanceFilter:
_ensureDouble((_flattenCompoundState(data))['distanceFilter']),
stationaryRadius: _ensureDouble(
(_flattenCompoundState(data))['stationaryRadius']),
locationTimeout:
_ensureInt((_flattenCompoundState(data))['locationTimeout']),
disableElasticity:
_ensureBool((_flattenCompoundState(data))['disableElasticity']),
elasticityMultiplier: _ensureDouble(
(_flattenCompoundState(data))['elasticityMultiplier']),
stopAfterElapsedMinutes: _ensureInt(
(_flattenCompoundState(data))['stopAfterElapsedMinutes']),
geofenceProximityRadius: _ensureInt(
(_flattenCompoundState(data))['geofenceProximityRadius']),
maxMonitoredGeofences: _ensureInt(
(_flattenCompoundState(data))['maxMonitoredGeofences']),
geofenceInitialTriggerEntry: _ensureBool(
(_flattenCompoundState(data))['geofenceInitialTriggerEntry']),
desiredOdometerAccuracy: _ensureDouble(
(_flattenCompoundState(data))['desiredOdometerAccuracy']),
useSignificantChangesOnly: _ensureBool(
(_flattenCompoundState(data))['useSignificantChangesOnly']),
disableLocationAuthorizationAlert: _ensureBool(
(_flattenCompoundState(
data))['disableLocationAuthorizationAlert']),
showsBackgroundLocationIndicator: _ensureBool(
(_flattenCompoundState(
data))['showsBackgroundLocationIndicator']),
enableTimestampMeta:
_ensureBool((_flattenCompoundState(data))['enableTimestampMeta']),
// Android Options
geofenceModeHighAccuracy: (_flattenCompoundState(data))['geofenceModeHighAccuracy'],
// ActivityRecognition
isMoving: _ensureBool((_flattenCompoundState(data))['isMoving']),
stopTimeout: _ensureInt((_flattenCompoundState(data))['stopTimeout']),
activityRecognitionInterval: _ensureInt((_flattenCompoundState(data))['activityRecognitionInterval']),
minimumActivityRecognitionConfidence: (_flattenCompoundState(data))['minimumActivityRecognitionConfidence'],
disableStopDetection: _ensureBool((_flattenCompoundState(data))['disableStopDetection']),
stopOnStationary: _ensureBool((_flattenCompoundState(data))['stopOnStationary']),
// HTTP & Persistence
url: (_flattenCompoundState(data))['url'],
persistMode: (_flattenCompoundState(data))['persistMode'],
method: (_flattenCompoundState(data))['method'],
httpRootProperty: (_flattenCompoundState(data))['httpRootProperty'],
params: _ensureStringKeyedMap((_flattenCompoundState(data))['params']),
headers: _ensureStringKeyedMap((_flattenCompoundState(data))['headers']),
extras: _ensureStringKeyedMap((_flattenCompoundState(data))['extras']),
autoSync: _ensureBool((_flattenCompoundState(data))['autoSync']),
autoSyncThreshold: (_flattenCompoundState(data))['autoSyncThreshold'],
disableAutoSyncOnCellular: _ensureBool((_flattenCompoundState(data))['disableAutoSyncOnCellular']),
disableProviderChangeRecord: _ensureBool((_flattenCompoundState(data))['disableProviderChangeRecord']),
batchSync: _ensureBool((_flattenCompoundState(data))['batchSync']),
maxBatchSize: (_flattenCompoundState(data))['maxBatchSize'],
locationTemplate: (_flattenCompoundState(data))['locationTemplate'],
geofenceTemplate: (_flattenCompoundState(data))['geofenceTemplate'],
maxDaysToPersist: (_flattenCompoundState(data))['maxDaysToPersist'],
maxRecordsToPersist: (_flattenCompoundState(data))['maxRecordsToPersist'],
locationsOrderDirection: (_flattenCompoundState(data))['locationsOrderDirection'],
httpTimeout: (_flattenCompoundState(data))['httpTimeout'],
authorization: ((_flattenCompoundState(data))['authorization'] != null) ? Authorization.fromMap(_ensureStringKeyedMap((_flattenCompoundState(data))['authorization'])) : null,
// Application
stopOnTerminate: _ensureBool((_flattenCompoundState(data))['stopOnTerminate']),
startOnBoot: _ensureBool((_flattenCompoundState(data))['startOnBoot']),
heartbeatInterval: _ensureInt((_flattenCompoundState(data))['heartbeatInterval']),
schedule: _ensureStringList((_flattenCompoundState(data))['schedule']),
// Logging & Debug
debug: _ensureBool((_flattenCompoundState(data))['debug']),
logLevel: (_flattenCompoundState(data))['logLevel'],
logMaxDays: (_flattenCompoundState(data))['logMaxDays'],
////
// iOS Options
//
// Geolocation Options
pausesLocationUpdatesAutomatically: _ensureBool((_flattenCompoundState(data))['pausesLocationUpdatesAutomatically']),
locationAuthorizationRequest: (_flattenCompoundState(data))['locationAuthorizationRequest'],
locationAuthorizationAlert: ((_flattenCompoundState(data))['locationAuthorizationAlert'] != null) ? _ensureStringKeyedMap((_flattenCompoundState(data))['locationAuthorizationAlert']) : null,
// Activity Recognition Options
activityType: (_flattenCompoundState(data))['activityType'],
stopDetectionDelay: _ensureInt((_flattenCompoundState(data))['stopDetectionDelay']),
disableMotionActivityUpdates: _ensureBool((_flattenCompoundState(data))['disableMotionActivityUpdates']),
// Application Options
preventSuspend: _ensureBool((_flattenCompoundState(data))['preventSuspend']),
////
// Android Options
//
// Geolocation Options
locationUpdateInterval: (_flattenCompoundState(data))['locationUpdateInterval'],
fastestLocationUpdateInterval: (_flattenCompoundState(data))['fastestLocationUpdateInterval'],
deferTime: (_flattenCompoundState(data))['deferTime'],
allowIdenticalLocations: (_flattenCompoundState(data))['allowIdenticalLocations'],
speedJumpFilter: (_flattenCompoundState(data))['speedJumpFilter'],
// Activity Recognition Options
triggerActivities: (_flattenCompoundState(data))['triggerActivities'],
motionTriggerDelay: (_flattenCompoundState(data))['motionTriggerDelay'],
// Application Options
enableHeadless: (_flattenCompoundState(data))['enableHeadless'],
scheduleUseAlarmManager: ((_flattenCompoundState(data))['scheduleUseAlarmManager'] != null) ? (_flattenCompoundState(data))['scheduleUseAlarmManager'] : false,
backgroundPermissionRationale: ((_flattenCompoundState(data))['backgroundPermissionRationale'] != null) ? PermissionRationale.fromMap(_ensureStringKeyedMap((_flattenCompoundState(data))['backgroundPermissionRationale'])) : null,
notification: ((_flattenCompoundState(data))['notification'] != null) ? Notification.fromMap(_ensureStringKeyedMap((_flattenCompoundState(data))['notification'])) : null) {
if (kDebugMode) {
_debugPrintStatePayload(data);
}
final Map flat = _flattenCompoundState(data);
enabled = _ensureBool(flat['enabled'])!;
isFirstBoot = _ensureBool(flat['isFirstBoot'])!;
trackingMode = flat['trackingMode'];
schedulerEnabled = _ensureBool(flat['schedulerEnabled'])!;
odometer = _ensureDouble(flat['odometer'])!;
didLaunchInBackground = (flat['didLaunchInBackground'] != null)
? _ensureBool(flat['didLaunchInBackground'])!
: false;
didDeviceReboot = (flat['didDeviceReboot'] != null)
? _ensureBool(flat['didDeviceReboot'])!
: false;
map = flat;
}