Map<String, Object?> toJson() => { 'name': name, 'width': width, 'height': height, if (source != null) 'source': source, 'root': root.toJson(), };