class PpmAttachments { PpmAttachments({ this.id, this.visitId, this.attachmentName, this.attachmentURL, }); PpmAttachments.fromJson(dynamic json) { id = json['id']; visitId = json['visitId']; attachmentName = json['attachmentName'] ?? json['attachmentURL']; // Handle potential null and prioritize'attachmentName' } num? id; // Now nullable num? visitId; // Now nullable String? attachmentName; // Now nullable String? attachmentURL; // Now nullable PpmAttachments copyWith({ num? id, num? visitId, String? attachmentName, String? attachmentURL, }) => PpmAttachments( id: id ?? this.id, visitId: visitId ?? this.visitId, attachmentName: attachmentName ?? this.attachmentName,attachmentURL: attachmentURL ?? this.attachmentURL, ); Map toJson() { final map = {}; map['id'] = id; map['visitId'] = visitId; map['attachmentName'] = attachmentName; map['attachmentURL'] = attachmentURL; return map; } }