transformAttachments function

List<AttachmentModel> transformAttachments(
  1. List<Map<String, dynamic>> attachments
)

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();