$UikTextPropsFromJson function

UikTextProps $UikTextPropsFromJson(
  1. Map<String, dynamic> json
)

Implementation

UikTextProps $UikTextPropsFromJson(Map<String, dynamic> json) {
  final UikTextProps uikTextProps = UikTextProps();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    uikTextProps.id = id;
  }
  final String? text = jsonConvert.convert<String>(json['text']);
  if (text != null) {
    uikTextProps.text = text;
  }
  final String? striketext = jsonConvert.convert<String>(json['striketext']);
  if (striketext != null) {
    uikTextProps.striketext = striketext;
  }

  final String? textAlign = jsonConvert.convert<String>(json['textAlign']);
  if (textAlign != null) {
    if (textAlign == "TextAlign.center") {
      uikTextProps.textAlign = TextAlign.center;
    }
    if (textAlign == "TextAlign.end") {
      uikTextProps.textAlign = TextAlign.end;
    }
    if (textAlign == "TextAlign.start") {
      uikTextProps.textAlign = TextAlign.start;
    }
    if (textAlign == "TextAlign.left") {
      uikTextProps.textAlign = TextAlign.left;
    }
    if (textAlign == "TextAlign.right") {
      uikTextProps.textAlign = TextAlign.right;
    }
    if (textAlign == "TextAlign.justify") {
      uikTextProps.textAlign = TextAlign.justify;
    }
  }

  final String? color = jsonConvert.convert<String>(json['color']);
  if (color != null) {
    uikTextProps.color = color.toColor();
  }
  final bool? strikethrough = jsonConvert.convert<bool>(json['isStrike']);
  if (strikethrough != null) {
    uikTextProps.isStrike = strikethrough;
  }

  final double? size = jsonConvert.convert<double>(json['size']);
  if (size != null) {
    uikTextProps.size = size;
  }

  final String? fontWeight = jsonConvert.convert<String>(json['fontWeight']);
  if (fontWeight != null) {
    if (fontWeight == "FontWeight.bold") {
      uikTextProps.fontWeight = FontWeight.bold;
    }
    if (fontWeight == "FontWeight.w100") {
      uikTextProps.fontWeight = FontWeight.w100;
    }
    if (fontWeight == "FontWeight.w200") {
      uikTextProps.fontWeight = FontWeight.w200;
    }
    if (fontWeight == "FontWeight.w300") {
      uikTextProps.fontWeight = FontWeight.w300;
    }
    if (fontWeight == "FontWeight.w400") {
      uikTextProps.fontWeight = FontWeight.w400;
    }
    if (fontWeight == "FontWeight.w500") {
      uikTextProps.fontWeight = FontWeight.w500;
    }
    if (fontWeight == "FontWeight.w600") {
      uikTextProps.fontWeight = FontWeight.w600;
    }
    if (fontWeight == "FontWeight.w700") {
      uikTextProps.fontWeight = FontWeight.w700;
    }
    if (fontWeight == "FontWeight.w800") {
      uikTextProps.fontWeight = FontWeight.w800;
    }
    if (fontWeight == "FontWeight.w900") {
      uikTextProps.fontWeight = FontWeight.w900;
    }
  }
  final String? fontFamily = jsonConvert.convert<String>(json['fontFamily']);
  if (fontFamily != null) {
    uikTextProps.fontFamily = fontFamily;
  }

  final double? leftMargin = jsonConvert.convert<double>(json["leftMargin"]);
  final double? rightMargin = jsonConvert.convert<double>(json["rightMargin"]);
  final double? topMargin = jsonConvert.convert<double>(json["topMargin"]);
  final double? bottomMargin =
      jsonConvert.convert<double>(json["bottomMargin"]);

  final bool? isStriken = jsonConvert.convert<bool>(json["isStriken"]);

  if (leftMargin != null) {
    uikTextProps.leftMargin = leftMargin;
  }
  if (topMargin != null) {
    uikTextProps.topMargin = topMargin;
  }
  if (bottomMargin != null) {
    uikTextProps.bottomMargin = bottomMargin;
  }
  if (rightMargin != null) {
    uikTextProps.rightMargin = rightMargin;
  }

  if (isStriken != null) {
    uikTextProps.isStriken = isStriken;
  }

  final UikAction? action = jsonConvert.convert<UikAction>(json['action']);
  if (action != null) {
    uikTextProps.action = action;
  }
  return uikTextProps;
}