fromMap static method

ContentBlockerTrigger fromMap(
  1. Map<String, dynamic> map
)

Implementation

static ContentBlockerTrigger fromMap(Map<String, dynamic> map) {
  List<ContentBlockerTriggerResourceType> resourceType = [];
  List<ContentBlockerTriggerLoadType> loadType = [];
  List<ContentBlockerTriggerLoadContext> loadContext = [];

  List<String> resourceTypeStringList =
      List<String>.from(map["resource-type"] ?? []);
  resourceTypeStringList.forEach((typeValue) {
    var type = ContentBlockerTriggerResourceType.fromNativeValue(typeValue);
    if (type != null) {
      resourceType.add(type);
    }
  });

  List<String> loadTypeStringList = List<String>.from(map["load-type"] ?? []);
  loadTypeStringList.forEach((typeValue) {
    var type = ContentBlockerTriggerLoadType.fromNativeValue(typeValue);
    if (type != null) {
      loadType.add(type);
    }
  });

  List<String> loadContextStringList =
      List<String>.from(map["load-context"] ?? []);
  loadContextStringList.forEach((typeValue) {
    var context = ContentBlockerTriggerLoadContext.fromNativeValue(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);
}