$UikColumnPropsFromJson function

UikColumnProps $UikColumnPropsFromJson(
  1. Map<String, dynamic> json
)

Implementation

UikColumnProps $UikColumnPropsFromJson(Map<String, dynamic> json) {
  final UikColumnProps uikColumnProps = UikColumnProps();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    uikColumnProps.id = id;
  }

  final List<dynamic>? widgets =
      jsonConvert.convert<List<dynamic>>(json["widgets"]);
  if (widgets != null) {
    for (int i = 0; i < widgets.length; i++) {
      if (widgets[i]["id"] == "image") {
        uikColumnProps.widgets.add(UikImage(
            WidgetType.UikImage, UikImageProps.fromJson(json["widgets"][i])));
      }

      if (widgets[i]["id"] == "text") {
        uikColumnProps.widgets.add(UikContainerText(WidgetType.UikText,
            UikContainerTextProps.fromJson(json["widgets"][i])));
      }

      if (widgets[i]["id"] == "avatar") {
        UiSdkUtils.prettyPrintJson(widgets[i]);

        uikColumnProps.widgets.add(UikAvatar(
            WidgetType.UikAvatar, UikAvatarProps.fromJson(json["widgets"][i])));
      }
      if (widgets[i]["id"] == "icon") {
        uikColumnProps.widgets.add(UikIcon(
            WidgetType.UikText, UikIconProps.fromJson(json["widgets"][i])));
      }

      if (widgets[i]["id"] == "text1") {
        // UiSdkUtils.prettyPrintJson(widgets[i]);

        uikColumnProps.widgets.add(UikText(
            WidgetType.UikText, UikTextProps.fromJson(json["widgets"][i])));
      }

      if (widgets[i]["id"] == "cell") {
        uikColumnProps.widgets.add(UikCell(
            WidgetType.UikText, UikCellProps.fromJson(json["widgets"][i])));
      }

      if (widgets[i]["id"] == "itext") {
        uikColumnProps.widgets.add(UikIconText(
            WidgetType.UikText, UikIconTextProps.fromJson(json["widgets"][i])));
      }

      if (widgets[i]["id"] == "button") {
        uikColumnProps.widgets.add(UikButton(
            WidgetType.UikText, UikButtonProps.fromJson(json["widgets"][i])));
      }

      if (widgets[i]["id"] == "twoRow") {
        uikColumnProps.widgets.add(UikTwoComponentRow(WidgetType.UikText,
            UikTwoComponentRowProps.fromJson(json["widgets"][i])));
      }
      if (widgets[i]["id"] == "productcards") {
        uikColumnProps.widgets.add(UikProductCardGrid(WidgetType.UikText,
            UikProductCardGridProps.fromJson(json["widgets"][i])));
      }
      if (widgets[i]["id"] == "container") {
        uikColumnProps.widgets.add(UikContainer(WidgetType.UikText,
            UikContainerProps.fromJson(json["widgets"][i])));
      }
    }
  }

  final double? leftMargin = jsonConvert.convert<double>(json["leftMargin"]);
  if (leftMargin != null) {
    uikColumnProps.leftMargin = leftMargin;
  }

  final double? height = jsonConvert.convert<double>(json["height"]);
  if (height != null) {
    uikColumnProps.height = height;
  }

  final double? rightMargin = jsonConvert.convert<double>(json["rightMargin"]);
  if (rightMargin != null) {
    uikColumnProps.rightMargin = rightMargin;
  }

  final double? topMargin = jsonConvert.convert<double>(json["topMargin"]);
  if (topMargin != null) {
    uikColumnProps.topMargin = topMargin;
  }

  final double? bottomMargin =
      jsonConvert.convert<double>(json["bottomMargin"]);
  if (bottomMargin != null) {
    uikColumnProps.bottomMargin = bottomMargin;
  }

  return uikColumnProps;
}