AttachmentModel.fromSpecificModel constructor

AttachmentModel.fromSpecificModel(
  1. Map<String, dynamic> payload,
  2. String attachType
)

Transforms the attachment object into a specific model, depending on its type. There may be exceptions VkDartException in the case of a non-correct object, or if the type is not supported

Implementation

factory AttachmentModel.fromSpecificModel(
        Map<String, dynamic> payload, String attachType) =>
    switch (attachType) {
      'photo' => PhotoAttachmentModel(payload),
      'video' => VideoAttachmentModel(payload),
      'audio' => AudioAttachmentModel(payload),
      'doc' => DocumentAttachmentModel(payload),
      'link' => LinkAttachmentModel(payload),
      'market' => MarketAttachmentModel(payload),
      'market_album' => MarketAlbumAttachmentModel(payload),
      'wall' => WallAttachmentModel(payload),
      'wall_reply' => WallReplyAttachmentModel(payload),
      'sticker' => StickerAttachmentModel(payload),
      'gift' => GiftAttachmentModel(payload),
      'graffiti' => GraffitiAttachmentModel(payload),
      'poll' => PollAttachmentModel(payload),
      'note' => NoteAttachmentModel(payload),
      'page' => WikiPageAttachmentModel(payload),
      _ => throw VkDartException('$attachType of attachment has no support!')
    };