VariationGroup.fromJson constructor

VariationGroup.fromJson(
  1. Map<String, dynamic> json
)

Implementation

VariationGroup.fromJson(Map<String, dynamic> json) {
  // Set idVariationGroup
  if (json.keys.contains("id")) {
    idVariationGroup = json['id'] as String;
  }

  // Set idVariationGroup Name
  if (json.keys.contains("name")) {
    variationGroupName = json['name'] as String;
  }

  // Create targeting
  if (json.keys.contains("targeting")) {
    targeting = Targeting.fromJson(json["targeting"]);
  }
  // Create variation
  var list = (json['variations'] ?? []) as List<dynamic>;
  variations = list.map((e) {
    return Variation.fromJson(e);
  }).toList();
}