class Attachment { final String name; final String path; final int? size; final String? mimeType; final String? baseUrl; // Add mimeType if available Attachment({required this.name, required this.path, this.size, this.mimeType, this.baseUrl}); bool get isImage { final ext = link.split('.').last.toLowerCase(); return ['jpg', 'jpeg', 'png', 'gif', 'webp'].contains(ext) || (mimeType?.startsWith('image/') ?? false); } bool get isVideo { final ext = link.split('.').last.toLowerCase(); return ['mp4', 'mov', 'webm', 'avi'].contains(ext) || (mimeType?.startsWith('video/') ?? false); } String get link => '$baseUrl/data$path'; factory Attachment.fromJson(Map json, String baseUrl) => Attachment( name: json['name'], path: json['path'], baseUrl: baseUrl, ); }