Map<String, Object?> toJson() => { if (name != null) 'name': name, if (metadata != null) 'metadata': metadata, };