import 'dart:convert'; ChatProfileModel chatProfileModelFromJson(String str) => ChatProfileModel.fromJson(json.decode(str)); String chatProfileModelToJson(ChatProfileModel data) => json.encode(data.toJson()); class ChatProfileModel { final bool status; final String profile; final String name; final String role; final List userUploadedDocuments; final List adminUploadedDocuments; ChatProfileModel({ required this.status, required this.profile, required this.name, required this.role, required this.userUploadedDocuments, required this.adminUploadedDocuments, }); factory ChatProfileModel.fromJson(Map json) => ChatProfileModel( status: json["status"] ?? false, profile: json["profile"] ?? "", name: json["name"] ?? "", role: json["role"] ?? "", userUploadedDocuments: json["userUploadedDocuments"] == null ? [] : List.from( json["userUploadedDocuments"] .map((x) => ChatDocument.fromJson(x)), ), adminUploadedDocuments: json["adminUploadedDocuments"] == null ? [] : List.from( json["adminUploadedDocuments"] .map((x) => ChatDocument.fromJson(x)), ), ); Map toJson() => { "status": status, "profile": profile, "name": name, "role": role, "userUploadedDocuments": userUploadedDocuments.map((x) => x.toJson()).toList(), "adminUploadedDocuments": adminUploadedDocuments.map((x) => x.toJson()).toList(), }; } class ChatDocument { final String fileName; final String filePath; final String fileType; ChatDocument({ required this.fileName, required this.filePath, required this.fileType, }); factory ChatDocument.fromJson(Map json) => ChatDocument( fileName: json["file_name"] ?? "", filePath: json["file_path"] ?? "", fileType: json["file_type"] ?? "", ); Map toJson() => { "file_name": fileName, "file_path": filePath, "file_type": fileType, }; }