Properties.fromJson constructor

Properties.fromJson(
  1. Map<String, dynamic> json,
  2. int type
)

Implementation

Properties.fromJson(Map<String, dynamic> json, int type) {
  orientation = json['orientation'];
  imageUrl = json['imageUrl'];
  asset = json['asset'];
  autoDimension = json['autoDimension'];
  arrowAutoDimension = json['arrowAutoDimensio'];
  gap = (json) {
    return json is int
        ? json.toDouble()
        : (json is String ? double.parse(json) : 5.0);
  }(json['gap']);
  arrowImageWidth = (json) {
    return json is int
        ? json.toDouble()
        : (json is String ? double.parse(json) : 5.0);
  }(json['arrowWidth']);
  arrowImageHeight = (json) {
    return json is int
        ? json.toDouble()
        : (json is String ? double.parse(json) : 5.0);
  }(json['arrowHeight']);
  text = json['text'];
  fontColor = json['fontColor'];
  fontSize = (json) {
    return json is int
        ? json.toDouble()
        : (json is String ? double.parse(json) : 14.0);
  }(json['fontSize']);
  fontWeight = json['fontWeight'];
  lineHeight = (json) {
    return json is int
        ? json.toDouble()
        : (json is String ? double.parse(json) : 1.0);
  }(json['lineHeight']);
  alignment = json['alignment'];
  margin = json['margin'] != null ? Margin.fromJson(json['margin']) : null;
  padding = json['padding'] != null ? Margin.fromJson(json['padding']) : null;
  autoLink = json['autoLink'];
  elevation = json['elevation']?.toDouble();
  hasBg = json['hasBg'];
  bgUrl = json['bgUrl'];
  bgColor = json['bgColor'];
  bgOpacity = (json) {
    return json is int
        ? json.toDouble()
        : (json is String ? double.parse(json) : 5.0);
  }(json['bgOpacity']);
  bgObjectFit = json['bgObjectFit'];
  bgWidth = json['bgWidth'];
  bgHeight = json['bgHeight'];
  bgTop = json['bgTop'];
  bgLeft = json['bgLeft'];
  hasBorder = json['hasBorder'];
  borderColor = json['borderColor'];
  borderOpacity = json['borderOpacity']?.toDouble();
  roundness = json['roundness']?.toDouble();
  border =
      json['border'] != null ? CustomBorder.fromJson(json['border']) : null;
  hasAction = json['hasAction'];
  clickType = json['clickType'];
  target = json['target'];
  hasTransition = json['hasTransition'];
  transition = json['transition'];

  color = json['color'];

  arrowImageUrl = json['arrowImageUrl'];

  if (type == 2 || type == 41 || type == 42) {
    if (json['height'] is int) {
      imageHeight = json['height'].toDouble();
      imageWidth = json['width'].toDouble();
    } else {
      imageHeight = int.parse(json['height']).toDouble();
      imageWidth = int.parse(json['width']).toDouble();
    }
  } else {
    height = json['height'];
    width = json['width'];
  }

  // if (type == 28) {
  //   if (json['arrowHeight'] is int) {
  //     imageHeight = json['arrowHeight'].toDouble();
  //     imageWidth = json['arrowWidth'].toDouble();
  //   } else {
  //     imageHeight = int.parse(json['arrowHeight']).toDouble();
  //     imageWidth = int.parse(json['arrowWidth']).toDouble();
  //   }
  // }

  style = json['style'];
  horizontalAlignment = json['horiAlignment'];
  verticalAlignment = json['verAlignment'];

  horizontalContentAlignment = json['horiContentAlignment'];
  verticalContentAlignment = json['verContentAlignment'];

  arrowColor = json['arrowColor'];

  size = json['size'];
  endDate = json['endDate'] != null
      ? DateTime.parse(json['endDate'])
      : DateTime.now();

  if (json['children'] != null) {
    children = <UIComponent>[];
    json['children'].forEach((v) {
      children!.add(UIComponent.fromJson(v));
    });
  }

  hasLines = json['hasLines'];
  lineColor = json['lineColor'];
  lineGap = json['gap'];
  lineStyle = json['lineStyle'];
  lineThickness = json['lineThickness'];

  constHeight = json['constHeight'];
  constWidth = json['constWidth'];

  currentCount = int.parse(json['curCount'] ?? '0');
  maxCount = int.parse(json['maxCount'] ?? '0');

  barColor = json['barColor'];
  barBgColor = json['barBgColor'];

  showToast = json['showToast'];
  toastMessage = json['toastMessage'];
  copyText = json['copyText'];

  shareText = json['shareText'];

  scratchCardAsset = json['sAsset'];
  openInModal = json['modal'];
}