$UikStackPropsFromJson function
Implementation
UikStackProps $UikStackPropsFromJson(Map<String, dynamic> json) {
final UikStackProps uikStackProps = UikStackProps();
final String? id = jsonConvert.convert<String>(json['id']);
if (id != null) {
uikStackProps.id = id;
}
final String? image = jsonConvert.convert<String>(json['image']);
if (image != null) {
uikStackProps.image = image;
}
final double? leftMargin = jsonConvert.convert<double>(json["leftMargin"]);
if (leftMargin != null) {
uikStackProps.leftMargin = leftMargin;
}
final double? lowerHeight = jsonConvert.convert<double>(json["lowerHeight"]);
if (lowerHeight != null) {
uikStackProps.lowerHeight = lowerHeight;
}
final double? rightMargin = jsonConvert.convert<double>(json["rightMargin"]);
if (rightMargin != null) {
uikStackProps.rightMargin = rightMargin;
}
final double? topMargin = jsonConvert.convert<double>(json["topMargin"]);
if (topMargin != null) {
uikStackProps.topMargin = topMargin;
}
final double? bottomMargin =
jsonConvert.convert<double>(json["bottomMargin"]);
if (bottomMargin != null) {
uikStackProps.bottomMargin = bottomMargin;
}
final bool? isGradient = jsonConvert.convert<bool>(json["isGradient"]);
final List<dynamic>? gradientColors =
jsonConvert.convert<List<dynamic>>(json["gradientColors"]);
if (gradientColors != null) {
// List<String> list = [];
// list.addAll(json["gradientColors"]);
uikStackProps.gradientColors = List.generate(
gradientColors.length,
(index) => gradientColors[index].toString().toColor(),
);
}
if (isGradient != null) {
uikStackProps.isGradient = isGradient;
}
final bool? isborder = jsonConvert.convert<bool>(json["isBorder"]);
if (isborder != null) {
uikStackProps.isborder = isborder;
final double? borderWidth =
jsonConvert.convert<double>(json["borderWidth"]);
if (borderWidth != null) {
uikStackProps.borderWidth = borderWidth;
}
final String? borderColor =
jsonConvert.convert<String>(json['borderColor']);
if (borderColor != null) {
uikStackProps.borderColor = borderColor.toColor();
}
final String? bgColor = jsonConvert.convert<String>(json['bgColor']);
if (bgColor != null) {
uikStackProps.bgColor = bgColor.toColor();
}
}
final List<dynamic>? stackItems =
jsonConvert.convert<List<dynamic>>(json['stackItems']);
if (stackItems != null) {
for (var i = 0; i < stackItems.length; i++) {
final double? leftPosition =
jsonConvert.convert<double>(stackItems[i]["leftPosition"]);
final double? rightPosition =
jsonConvert.convert<double>(stackItems[i]["rightPosition"]);
final double? topPosition =
jsonConvert.convert<double>(stackItems[i]["topPosition"]);
final double? bottomPosition =
jsonConvert.convert<double>(stackItems[i]["bottomPosition"]);
if (stackItems[i]['id'] == 'image') {
uikStackProps.stackItems.add(
Positioned(
left: leftPosition,
right: rightPosition,
top: topPosition,
bottom: bottomPosition,
child: UikImage(
WidgetType.UikText,
UikImageProps.fromJson(stackItems[i]),
),
),
);
} else if (stackItems[i]['id'] == 'container') {
uikStackProps.stackItems.add(
Positioned(
left: leftPosition,
right: rightPosition,
top: topPosition,
bottom: bottomPosition,
child: UikContainer(
WidgetType.UikText,
UikContainerProps.fromJson(stackItems[i]),
),
),
);
} else if (stackItems[i]['id'] == 'button') {
uikStackProps.stackItems.add(
Positioned(
left: leftPosition,
right: rightPosition,
top: topPosition,
bottom: bottomPosition,
child: Center(
child: UikButton(
WidgetType.UikText,
UikButtonProps.fromJson(stackItems[i]),
),
),
),
);
}
}
}
final String? widget = jsonConvert.convert<String>(json["widget"]);
if (widget != null) {
if (json["widget"]["id"] == "simpleColumn") {
uikStackProps.widget = UikSimpleColumn(
WidgetType.UikText, UikSimpleColumnProps.fromJson(json["widget"]));
}
} else {
uikStackProps.widget = null;
}
return uikStackProps;
}