Constraints.fromMap constructor
Create from map.
Implementation
factory Constraints.fromMap(Map<String, dynamic> map) => Constraints(
requiresNetwork: map['requiresNetwork'] as bool? ?? false,
requiresUnmeteredNetwork:
map['requiresUnmeteredNetwork'] as bool? ?? false,
requiresCharging: map['requiresCharging'] as bool? ?? false,
requiresDeviceIdle: map['requiresDeviceIdle'] as bool? ?? false,
requiresBatteryNotLow: map['requiresBatteryNotLow'] as bool? ?? false,
requiresStorageNotLow: map['requiresStorageNotLow'] as bool? ?? false,
allowWhileIdle: map['allowWhileIdle'] as bool? ?? false,
isHeavyTask: map['isHeavyTask'] as bool? ?? false,
qos: QoS.values.firstWhere(
(e) => e.name == map['qos'],
orElse: () => QoS.background,
),
exactAlarmIOSBehavior: ExactAlarmIOSBehavior.values.firstWhere(
(e) => e.name == map['exactAlarmIOSBehavior'],
orElse: () => ExactAlarmIOSBehavior.showNotification,
),
backoffPolicy: BackoffPolicy.values.firstWhere(
(e) => e.name == map['backoffPolicy'],
orElse: () => BackoffPolicy.exponential,
),
backoffDelayMs: map['backoffDelayMs'] as int? ?? 30000,
maxRetries: map['maxRetries'] as int? ?? 3,
systemConstraints: (map['systemConstraints'] as List<dynamic>?)
?.map((name) => SystemConstraint.values
.where(
(e) => e.name == name,
)
.firstOrNull)
.whereType<SystemConstraint>()
.toSet() ??
{},
bgTaskType: map['bgTaskType'] != null
? BGTaskType.values
.where(
(e) => e.name == map['bgTaskType'],
)
.firstOrNull
: null,
foregroundServiceType: map['foregroundServiceType'] != null
? ForegroundServiceType.values
.where(
(e) => e.name == map['foregroundServiceType'],
)
.firstOrNull
: null,
);