Properties.fromJson constructor
Implementation
Properties.fromJson(Map<String, dynamic> json, String type) {
orientation = json['orientation'];
imageUrl = json['imageUrl'];
autoDimension = json['autoDimension'];
arrowAutoDimension = json['arrowAutoDimensio'];
gap = (json) {
return json is int
? json.toDouble()
: (json is String ? double.parse(json) : 5.0);
}(json['gap']);
arrowImageWidth = (json) {
return json is int
? json.toDouble()
: (json is String ? double.parse(json) : 5.0);
}(json['arrowWidth']);
arrowImageHeight = (json) {
return json is int
? json.toDouble()
: (json is String ? double.parse(json) : 5.0);
}(json['arrowHeight']);
text = json['text'];
fontColor = json['fontColor'];
fontSize = (json) {
return json is int
? json.toDouble()
: (json is String ? double.parse(json) : 14.0);
}(json['fontSize']);
fontWeight = json['fontWeight'];
lineHeight = (json) {
return json is int
? json.toDouble()
: (json is String ? double.parse(json) : 1.0);
}(json['lineHeight']);
alignment = json['alignment'];
margin = json['margin'] != null ? Margin.fromJson(json['margin']) : null;
padding = json['padding'] != null ? Margin.fromJson(json['padding']) : null;
autoLink = json['autoLink'];
elevation = json['elevation']?.toDouble();
hasBg = json['hasBg'];
bgUrl = json['bgUrl'];
bgColor = json['bgColor'];
bgOpacity = (json) {
return json is int
? json.toDouble()
: (json is String ? double.parse(json) : 5.0);
}(json['bgOpacity']);
hasBorder = json['hasBorder'];
borderColor = json['borderColor'];
borderOpacity = json['borderOpacity']?.toDouble();
roundness = json['roundness']?.toDouble();
border =
json['border'] != null ? CustomBorder.fromJson(json['border']) : null;
hasAction = json['hasAction'];
clickType = json['clickType'];
target = json['target'];
hasTransition = json['hasTransition'];
transition = json['transition'];
color = json['color'];
arrowImageUrl = json['arrowImageUrl'];
if (type == 'image') {
if (json['height'] is int) {
imageHeight = json['height'].toDouble();
imageWidth = json['width'].toDouble();
} else {
imageHeight = int.parse(json['height']).toDouble();
imageWidth = int.parse(json['width']).toDouble();
}
} else {
height = json['height'];
width = json['width'];
}
if (type == 'swipe') {
if (json['arrowHeight'] is int) {
imageHeight = json['arrowHeight'].toDouble();
imageWidth = json['arrowWidth'].toDouble();
} else {
imageHeight = int.parse(json['arrowHeight']).toDouble();
imageWidth = int.parse(json['arrowWidth']).toDouble();
}
}
style = json['style'];
horizontalAlignment = json['horiAlignment'];
verticalAlignment = json['verAlignment'];
horizontalContentAlignment = json['horiContentAlignment'];
verticalContentAlignment = json['verContentAlignment'];
arrowColor = json['arrowColor'];
size = json['size'];
endDate = json['endDate'] != null
? DateTime.parse(json['endDate'])
: DateTime.now();
if (json['children'] != null) {
children = <UIComponent>[];
json['children'].forEach((v) {
children!.add(UIComponent.fromJson(v));
});
}
}