$UikCardPropsFromJson function

UikCardProps $UikCardPropsFromJson(
  1. Map<String, dynamic> json
)

Implementation

UikCardProps $UikCardPropsFromJson(Map<String, dynamic> json) {
  UikCardProps uikCardProps = UikCardProps();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    uikCardProps.id = id;
  }
  final String? color = jsonConvert.convert<String>(json['color']);
  if (color != null) {
    uikCardProps.color = color.toColor();
  }
  final double? height = jsonConvert.convert(json['height']);
  if (height != null) {
    uikCardProps.height = height;
  }
  final double? elevation = jsonConvert.convert(json["elevation"]);
  if (elevation != null) {
    uikCardProps.elevation = elevation;
  }
  final String? titlePosition =
      jsonConvert.convert<String>(json['titlePosition']);
  if (titlePosition != null) {
    if (titlePosition == 'start') {
      uikCardProps.titlePosition = UikPosition.start;
    } else {
      uikCardProps.titlePosition = UikPosition.end;
    }
  }
  final String? shape = jsonConvert.convert<String>(json['shape']);
  if (shape != null) {
    uikCardProps.shape = RoundedRectangleBorder(
      borderRadius: BorderRadius.all(Radius.circular(8)),
    );
  }
  final String? clipBehavior =
      jsonConvert.convert<String>(json['clipBehavior']);
  if (clipBehavior != null) {
    if (clipBehavior == 'antiAliasWithSaveLayer') {
      uikCardProps.clipBehavior = Clip.antiAliasWithSaveLayer;
    } else if (clipBehavior == 'antiAlias') {
      uikCardProps.clipBehavior = Clip.antiAlias;
    } else if (clipBehavior == 'hardEdge') {
      uikCardProps.clipBehavior = Clip.hardEdge;
    } else {
      uikCardProps.clipBehavior = Clip.none;
    }
  }
  final double? margin = jsonConvert.convert(json['margin']);
  if (margin != null) {
    uikCardProps.margin = EdgeInsets.symmetric(
      horizontal: margin,
      vertical: margin,
    );
  }
  final double? padding = jsonConvert.convert(json['padding']);
  if (padding != null) {
    uikCardProps.padding = EdgeInsets.symmetric(
      horizontal: padding,
      vertical: padding,
    );
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  final String? contentType = jsonConvert.convert(json['contentType']);
  if (content != null) {
    if (contentType == 'text') {
      uikCardProps.content = UikText(
        WidgetType.UikText,
        UikTextProps.fromJson(
          json['content'],
        ),
      );
    } else if (contentType == "list") {
      uikCardProps.content = Column(
        children: _getListOfWidgets(json['content']),
      );
    } else if (contentType == "threecolumn") {
      uikCardProps.content = UikThreeColumnTile(
        WidgetType.UikText,
        UikThreeColumnTileProps.fromJson(
          json['content'],
        ),
      );
    }
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    uikCardProps.title = UikGWListTile(
      WidgetType.UikGWListTile,
      UikGWListTileProps.fromJson(json['title']),
    );
  }
  final bool? borderOnForeground =
      jsonConvert.convert(json['borderOnForeground']);
  if (borderOnForeground != null) {
    uikCardProps.borderOnForeground = borderOnForeground;
  }
  final bool? showImage = jsonConvert.convert(json['showImage']);
  if (showImage != null) {
    uikCardProps.showImage = showImage;
  }
  final bool? showOverlayImage = jsonConvert.convert(json['showOverlayImage']);
  if (showOverlayImage != null) {
    uikCardProps.showOverlayImage = showOverlayImage;
  }
  final String? image = jsonConvert.convert<String>(json['image']);
  if (image != null) {
    final Map<String, dynamic>? heightandwidthimage =
        jsonConvert.convert<Map<String, dynamic>>(json['heightandwidthimage']);
    if (heightandwidthimage != null) {
      uikCardProps.image = UikImage(
          WidgetType.UikImage, UikImageProps.fromJson(heightandwidthimage));
      // final double? heightImage =
      //     jsonConvert.convert(heightandwidthimage['height']);
      // final double? widthImage =
      //     jsonConvert.convert(heightandwidthimage['width']);
      // uikCardProps.image = Image(
      //   image: NetworkImage(image),
      //   width: widthImage,
      //   height: heightImage,
      // );
    } else {
      uikCardProps.image = Image(
        image: NetworkImage(image),
        fit: BoxFit.fitWidth,
      );
    }
  }
  // final String? imageOverlay =
  //     jsonConvert.convert<String>(json['imageOverlay']);
  // if (imageOverlay != null) {
  //   uikCardProps.imageOverlay = NetworkImage(imageOverlay);
  // }
  final String? buttonBar = jsonConvert.convert(json['buttonBar']);
  if (buttonBar != null) {
    uikCardProps.buttonBar = UikButtonBar(
        WidgetType.UikButtonBar, UikButtonBarProps.fromJson(json['buttonBar']));
  }
  final double? borderRadius = jsonConvert.convert(json['borderRadius']);
  if (borderRadius != null) {
    uikCardProps.borderRadius = BorderRadius.all(Radius.circular(borderRadius));
  }
  // final String? border = jsonConvert.convert<String>(json['border']);
  // if (border != null) {
  //   uikCardProps.border = Border();
  // }
  final List<String>? gradient = jsonConvert.convert(json['gradient']);
  if (gradient != null) {
    List<Color> colors = [];
    for (var color = 0; color < gradient.length; color++) {
      colors.add(gradient[color].toColor());
    }

    uikCardProps.gradient = LinearGradient(colors: colors);
  }
  final String? overlayImage = jsonConvert.convert(json['overlayImage']);
  if (overlayImage != null) {
    uikCardProps.overlayImage = UikImageOverlay(WidgetType.UikImageOverlay,
        UikImageOverlayProps.fromJson(json['overlayImage']));
  }

  return uikCardProps;
}