ForegroundServiceConfig.fromMap constructor
Creates a ForegroundServiceConfig from a map.
Implementation
factory ForegroundServiceConfig.fromMap(Map<String, Object?> map) {
final rawActions = map['actions'];
final actionsList = <String>[];
if (rawActions is List) {
for (final item in rawActions) {
if (item is String) actionsList.add(item);
}
}
return ForegroundServiceConfig(
enabled: ensureBool(map['enabled'], fallback: true),
channelId: map['channelId'] as String? ?? 'tracelet_channel',
channelName: map['channelName'] as String? ?? 'Tracelet',
notificationTitle: map['notificationTitle'] as String? ?? 'Tracelet',
notificationText:
map['notificationText'] as String? ??
'Tracking location in background',
notificationColor: map['notificationColor'] as String?,
notificationSmallIcon: map['notificationSmallIcon'] as String?,
notificationLargeIcon: map['notificationLargeIcon'] as String?,
notificationPriority: ensureInt(map['notificationPriority'], fallback: 0),
notificationOngoing: ensureBool(
map['notificationOngoing'],
fallback: true,
),
actions: actionsList,
);
}