fromMap static method
Implementation
static ContentBlockerTrigger fromMap(
Map<String, dynamic> map, {
EnumMethod? enumMethod,
}) {
List<ContentBlockerTriggerResourceType> resourceType = [];
List<ContentBlockerTriggerLoadType> loadType = [];
List<ContentBlockerTriggerLoadContext> loadContext = [];
List<String> resourceTypeStringList = List<String>.from(
map["resource-type"] ?? [],
);
resourceTypeStringList.forEach((typeValue) {
var type = switch (enumMethod ?? EnumMethod.nativeValue) {
EnumMethod.nativeValue =>
ContentBlockerTriggerResourceType.fromNativeValue(typeValue),
EnumMethod.value => ContentBlockerTriggerResourceType.fromValue(
typeValue,
),
EnumMethod.name => ContentBlockerTriggerResourceType.byName(typeValue),
};
if (type != null) {
resourceType.add(type);
}
});
List<String> loadTypeStringList = List<String>.from(map["load-type"] ?? []);
loadTypeStringList.forEach((typeValue) {
var type = switch (enumMethod ?? EnumMethod.nativeValue) {
EnumMethod.nativeValue => ContentBlockerTriggerLoadType.fromNativeValue(
typeValue,
),
EnumMethod.value => ContentBlockerTriggerLoadType.fromValue(typeValue),
EnumMethod.name => ContentBlockerTriggerLoadType.byName(typeValue),
};
if (type != null) {
loadType.add(type);
}
});
List<String> loadContextStringList = List<String>.from(
map["load-context"] ?? [],
);
loadContextStringList.forEach((typeValue) {
var context = switch (enumMethod ?? EnumMethod.nativeValue) {
EnumMethod.nativeValue =>
ContentBlockerTriggerLoadContext.fromNativeValue(typeValue),
EnumMethod.value => ContentBlockerTriggerLoadContext.fromValue(
typeValue,
),
EnumMethod.name => ContentBlockerTriggerLoadContext.byName(typeValue),
};
if (context != null) {
loadContext.add(context);
}
});
return ContentBlockerTrigger(
urlFilter: map["url-filter"],
ifFrameUrl: List<String>.from(map["if-frame-url"] ?? []),
urlFilterIsCaseSensitive: map["url-filter-is-case-sensitive"],
ifDomain: List<String>.from(map["if-domain"] ?? []),
unlessDomain: List<String>.from(map["unless-domain"] ?? []),
resourceType: resourceType,
loadType: loadType,
ifTopUrl: List<String>.from(map["if-top-url"] ?? []),
unlessTopUrl: List<String>.from(map["unless-top-url"] ?? []),
loadContext: loadContext,
);
}