transformAttachments function
Transforms a list of attachment objects in the format:
[{'type': 'photo', 'photo': {...}}, {'type': 'audio', 'audio': {...}}, ...]
in the attachment model.
Implementation
List<AttachmentModel> transformAttachments(
List<Map<String, dynamic>> attachments) =>
attachments.map((e) {
final attachType = e['type'];
return AttachmentModel.fromSpecificModel(e[attachType], attachType);
}).toList();