Map<String, dynamic> toJson() { return { 'name': name, 'status': status.name, if (metadata != null) 'metadata': metadata!.toJson(), }; }