fromJson static method
Implementation
static Attachment fromJson(Map<String, dynamic> json) {
final type = json['type'] as String;
return switch (type) {
'image' => PhotoAttachment.fromJson(json),
'video' => VideoAttachment.fromJson(json),
'audio' => AudioAttachment.fromJson(json),
'file' => FileAttachment.fromJson(json),
'sticker' => StickerAttachment.fromJson(json),
'contact' => ContactAttachment.fromJson(json),
'share' => ShareAttachment.fromJson(json),
'location' => LocationAttachment.fromJson(json),
'inline_keyboard' => InlineKeyboardAttachment.fromJson(json),
_ => throw ArgumentError('Unknown attachment type: $type'),
};
}