BrazeContentCard constructor

BrazeContentCard(
  1. String _data
)

Implementation

BrazeContentCard(String _data) {
  contentCardJsonString = _data;
  var contentCardJson = json.jsonDecode(_data);

  var clickedJson = contentCardJson["cl"];
  if (clickedJson is bool) {
    clicked = clickedJson;
  }
  var createdJson = contentCardJson["ca"];
  if (createdJson is int) {
    created = createdJson;
  }
  var descriptionJson = contentCardJson["ds"];
  if (descriptionJson is String) {
    description = descriptionJson;
  }
  var dismissableJson = contentCardJson["db"];
  if (dismissableJson is bool) {
    dismissable = dismissableJson;
  }
  var expiresAtJson = contentCardJson["ea"];
  if (expiresAtJson is int) {
    expiresAt = expiresAtJson;
  }
  var extrasJson = contentCardJson["e"];
  if (extrasJson is Map<String, dynamic>) {
    extrasJson.forEach((key, value) {
      if (extrasJson[key] is String) {
        extras[key] = value;
      }
    });
  }
  var idJson = contentCardJson["id"];
  if (idJson is String) {
    id = idJson;
  }
  var imageJson = contentCardJson["i"];
  if (imageJson is String) {
    image = imageJson;
  }
  var imageAspectRatioJson = contentCardJson["ar"];
  if (imageAspectRatioJson is num) {
    imageAspectRatio = imageAspectRatioJson;
  }
  var linkTextJson = contentCardJson["dm"];
  if (linkTextJson is String) {
    linkText = linkTextJson;
  }
  var pinnedJson = contentCardJson["p"];
  if (pinnedJson is bool) {
    pinned = pinnedJson;
  }
  var removedJson = contentCardJson["r"];
  if (removedJson is bool) {
    removed = removedJson;
  }
  var titleJson = contentCardJson["tt"];
  if (titleJson is String) {
    title = titleJson;
  }
  var typeJson = contentCardJson["tp"];
  if (typeJson is String) {
    type = typeJson;
  }
  if (type == "control") {
    isControl = true;
  }
  var urlJson = contentCardJson["u"];
  if (urlJson is String) {
    url = urlJson;
  }
  var useWebViewJson = contentCardJson["uw"];
  if (useWebViewJson is bool) {
    useWebView = useWebViewJson;
  }
  var viewedJson = contentCardJson["v"];
  if (viewedJson is bool) {
    viewed = viewedJson;
  }
}