GlareBox.fromJson constructor
GlareBox.fromJson(
- dynamic json
Implementation
factory GlareBox.fromJson(dynamic json) {
// Handle both array format [x, y, width, height] and object format
if (json is List && json.length >= 4) {
return GlareBox(
x: (json[0] as num?)?.toDouble(),
y: (json[1] as num?)?.toDouble(),
width: (json[2] as num?)?.toDouble(),
height: (json[3] as num?)?.toDouble(),
);
} else if (json is Map<String, dynamic>) {
return GlareBox(
x: (json['x'] as num?)?.toDouble(),
y: (json['y'] as num?)?.toDouble(),
width: (json['width'] as num?)?.toDouble(),
height: (json['height'] as num?)?.toDouble(),
);
}
// Fallback for invalid data
return const GlareBox();
}