fromJson static method
Implementation
static OverlayLayerData fromJson(Map<dynamic, dynamic> json) {
var layer = OverlayLayerData(
color: Color(json['color']),
opacityValue: (json['opacity'] ?? 1.0).toDouble(),
shape: OverlayShape.values[json['shape']],
size: (json['size'] ?? 100.0).toDouble(),
overlayType: OverlayType.values[json['overlayType']],
overlayImage: json['hasImage'] == true && json['overlayImage'] != null
? ImageItem.fromJson(json['overlayImage'])
: null,
);
if (json['offset'] != null) {
if (json['offset'] is Map) {
layer.offset = Offset(
(json['offset']['dx'] ?? 0).toDouble(),
(json['offset']['dy'] ?? 0).toDouble(),
);
} else if (json['offset'] is List && json['offset'].length == 2) {
layer.offset = Offset(
(json['offset'][0] ?? 0).toDouble(),
(json['offset'][1] ?? 0).toDouble(),
);
}
}
layer.rotation = (json['rotation'] ?? 0).toDouble();
layer.scale = (json['scale'] ?? 1).toDouble();
return layer;
}