$UikButtonPropsFromJson function
Implementation
UikButtonProps $UikButtonPropsFromJson(Map<String, dynamic> json) {
final UikButtonProps uikButtonProps = UikButtonProps();
final String? id = jsonConvert.convert<String>(json['id']);
if (id != null) {
uikButtonProps.id = id;
}
final String? text = jsonConvert.convert<String>(json['text']);
if (text != null) {
uikButtonProps.text =
UikText(WidgetType.UikText, UikTextProps.fromJson(json['text']));
}
final String? borderColor = jsonConvert.convert<String>(json['borderColor']);
if (borderColor != null) {
uikButtonProps.borderColor = borderColor.toColor();
}
String? backgroundColor =
jsonConvert.convert<String>(json['backgroundColor']);
if (backgroundColor != null) {
uikButtonProps.backgroundColor = backgroundColor.toColor();
}
final double? width = jsonConvert.convert<double>(json['width']);
if (width != null) {
uikButtonProps.width = width;
} else {
uikButtonProps.width = null;
}
final double? height = jsonConvert.convert<double>(json['height']);
if (height != null) {
uikButtonProps.height = height;
} else {
uikButtonProps.height = null;
}
final double? verticalPadding =
jsonConvert.convert<double>(json['verticalPadding']);
if (verticalPadding != null) {
uikButtonProps.verticalPadding = verticalPadding;
}
final double? horizontalPadding =
jsonConvert.convert<double>(json['horizontalPadding']);
if (horizontalPadding != null) {
uikButtonProps.horizontalPadding = horizontalPadding;
}
final double? borderRadius =
jsonConvert.convert<double>(json['borderRadius']);
if (borderRadius != null) {
uikButtonProps.borderRadius = borderRadius;
}
final String? icon = jsonConvert.convert<String>(json['icon']);
if (icon != null) {
if (json['icon']['id'] == 'icon') {
uikButtonProps.icon =
UikIcon(WidgetType.UikText, UikIconProps.fromJson(json['icon']));
} else if (json['icon']['id'] == 'text') {
UiSdkUtils.prettyPrintJson(json['icon']);
uikButtonProps.icon =
UikText(WidgetType.UikText, UikTextProps.fromJson(json['icon']));
} else if (json['icon']['id'] == 'image') {
uikButtonProps.icon =
UikImage(WidgetType.UikImage, UikImageProps.fromJson(json["icon"]));
}
}
final double? leftMargin = jsonConvert.convert<double>(json['leftMargin']);
if (leftMargin != null) {
uikButtonProps.leftMargin = leftMargin;
}
final double? rightMargin = jsonConvert.convert<double>(json['rightMargin']);
if (rightMargin != null) {
uikButtonProps.rightMargin = rightMargin;
}
final double? topMargin = jsonConvert.convert<double>(json['topMargin']);
if (topMargin != null) {
uikButtonProps.topMargin = topMargin;
}
final double? bottomMargin =
jsonConvert.convert<double>(json['bottomMargin']);
if (bottomMargin != null) {
uikButtonProps.bottomMargin = bottomMargin;
}
final UikAction? action = jsonConvert.convert<UikAction>(json['action']);
if (action != null) {
uikButtonProps.action = action;
}
return uikButtonProps;
}