Message.fromJson constructor

Message.fromJson(
  1. Map<String, dynamic> json
)

Creates a Message object from json map.

Implementation

factory Message.fromJson(Map<String, dynamic> json) {
  return Message(
    messageId: json['message_id'],
    from: _parseJson<User>(json['from'], User.fromJson),
    senderChat: _parseJson<Chat>(json['sender_chat'], Chat.fromJson),
    date: json['date'],
    chat: Chat.fromJson(json['chat']),
    replyToMessage:
        _parseJson<Message>(json['reply_to_message'], Message.fromJson),
    viaBot: _parseJson<User>(json['via_bot'], User.fromJson),
    editDate: json['edit_date'],
    mediaGroupId: json['media_group_id'],
    authorSignature: json['author_signature'],
    text: json['text'],
    entities:
        _parseList<MessageEntity>(json['entities'], MessageEntity.fromJson),
    animation: _parseJson<Animation>(json['animation'], Animation.fromJson),
    audio: _parseJson<Audio>(json['audio'], Audio.fromJson),
    document: _parseJson<Document>(json['document'], Document.fromJson),
    photo: _parseList<PhotoSize>(json['photo'], PhotoSize.fromJson),
    sticker: _parseJson<Sticker>(json['sticker'], Sticker.fromJson),
    video: _parseJson<Video>(json['video'], Video.fromJson),
    videoNote: _parseJson<VideoNote>(json['video_note'], VideoNote.fromJson),
    voice: _parseJson<Voice>(json['voice'], Voice.fromJson),
    caption: json['caption'],
    captionEntities: _parseList<MessageEntity>(
      json['caption_entities'],
      MessageEntity.fromJson,
    ),
    contact: _parseJson<Contact>(json['contact'], Contact.fromJson),
    dice: _parseJson<Dice>(json['dice'], Dice.fromJson),
    game: _parseJson<Game>(json['game'], Game.fromJson),
    poll: _parseJson<Poll>(json['poll'], Poll.fromJson),
    venue: _parseJson<Venue>(json['venue'], Venue.fromJson),
    location: _parseJson<Location>(json['location'], Location.fromJson),
    newChatMembers: _parseList<User>(json['new_chat_members'], User.fromJson),
    leftChatMember: _parseJson<User>(json['left_chat_member'], User.fromJson),
    newChatTitle: json['new_chat_title'],
    newChatPhoto:
        _parseList<PhotoSize>(json['new_chat_photo'], PhotoSize.fromJson),
    deleteChatPhoto: json['delete_chat_photo'],
    groupChatCreated: json['group_chat_created'],
    supergroupChatCreated: json['supergroup_chat_created'],
    channelChatCreated: json['channel_chat_created'],
    messageAutoDeleteTimerChanged: _parseJson<MessageAutoDeleteTimerChanged>(
      json['message_auto_delete_timer_changed'],
      MessageAutoDeleteTimerChanged.fromJson,
    ),
    migrateToChatId: json['migrate_to_chat_id'],
    migrateFromChatId: json['migrate_from_chat_id'],
    pinnedMessage:
        _parseJson<Message>(json['pinned_message'], Message.fromJson),
    invoice: _parseJson<Invoice>(json['invoice'], Invoice.fromJson),
    successfulPayment: _parseJson<SuccessfulPayment>(
      json['successful_payment'],
      SuccessfulPayment.fromJson,
    ),
    connectedWebsite: json['connected_website'],
    passportData: _parseJson<PassportData>(
      json['passport_data'],
      PassportData.fromJson,
    ),
    proximityAlertTriggered: _parseJson<ProximityAlertTriggered>(
      json['proximity_alert_triggered'],
      ProximityAlertTriggered.fromJson,
    ),
    replyMarkup: _parseJson<InlineKeyboardMarkup>(
      json['reply_markup'],
      InlineKeyboardMarkup.fromJson,
    ),
    isAutomaticForward: json['is_automatic_forward'],
    webAppData:
        _parseJson<WebAppData>(json['web_app_data'], WebAppData.fromJson),
    videoChatEnded: _parseJson<VideoChatEnded>(
      json['video_chat_ended'],
      VideoChatEnded.fromJson,
    ),
    videoChatStarted: _parseJson<VideoChatStarted>(
      json['video_chat_started'],
      VideoChatStarted.fromJson,
    ),
    videoChatParticipantsInvited: _parseJson<VideoChatParticipantsInvited>(
      json['video_chat_participants_invited'],
      VideoChatParticipantsInvited.fromJson,
    ),
    videoChatScheduled: _parseJson<VideoChatScheduled>(
      json['video_chat_scheduled'],
      VideoChatScheduled.fromJson,
    ),
    forumTopicClosed: _parseJson<ForumTopicClosed>(
      json['forum_topic_closed'],
      ForumTopicClosed.fromJson,
    ),
    forumTopicCreated: _parseJson<ForumTopicCreated>(
      json['forum_topic_created'],
      ForumTopicCreated.fromJson,
    ),
    forumTopicReopened: _parseJson<ForumTopicReopened>(
      json['forum_topic_reopened'],
      ForumTopicReopened.fromJson,
    ),
    hasProtectedContent: json['has_protected_content'],
    isTopicMessage: json['is_topic_message'],
    messageThreadId: json['message_thread_id'],
    usersShared:
        _parseJson<UsersShared>(json['users_shared'], UsersShared.fromJson),
    chatShared:
        _parseJson<ChatShared>(json['chat_shared'], ChatShared.fromJson),
    hasMediaSpoiler: json['has_media_spoiler'],
    forumTopicEdited: _parseJson<ForumTopicEdited>(
      json['forum_topic_edited'],
      ForumTopicEdited.fromJson,
    ),
    generalForumTopicHidden: _parseJson<GeneralForumTopicHidden>(
      json['general_forum_topic_hidden'],
      GeneralForumTopicHidden.fromJson,
    ),
    generalForumTopicUnhidden: _parseJson<GeneralForumTopicUnhidden>(
      json['general_forum_topic_unhidden'],
      GeneralForumTopicUnhidden.fromJson,
    ),
    writeAccessAllowed: _parseJson<WriteAccessAllowed>(
      json['write_access_allowed'],
      WriteAccessAllowed.fromJson,
    ),
    story: _parseJson<Story>(json['story'], Story.fromJson),
    externalReply: _parseJson<ExternalReplyInfo>(
      json['external_reply'],
      ExternalReplyInfo.fromJson,
    ),
    quote: _parseJson<TextQuote>(json['quote'], TextQuote.fromJson),
    linkPreviewOptions: _parseJson<LinkPreviewOptions>(
      json['link_preview_options'],
      LinkPreviewOptions.fromJson,
    ),
    giveaway: _parseJson<Giveaway>(json['giveaway'], Giveaway.fromJson),
    giveawayCreated: _parseJson<GiveawayCreated>(
      json['giveaway_created'],
      GiveawayCreated.fromJson,
    ),
    giveawayWinners: _parseJson<GiveawayWinners>(
      json['giveaway_winners'],
      GiveawayWinners.fromJson,
    ),
    giveawayCompleted: _parseJson<GiveawayCompleted>(
      json['giveaway_completed'],
      GiveawayCompleted.fromJson,
    ),
    forwardOrigin: _parseJson<MessageOrigin>(
      json['forward_origin'],
      MessageOrigin.fromJson,
    ),
    boostAdded: _parseJson<ChatBoostAdded>(
      json['boost_added'],
      ChatBoostAdded.fromJson,
    ),
    senderBoostCount: json["sender_boost_count"],
    replyToStory: _parseJson<Story>(json["reply_to_story"], Story.fromJson),
    businessConnectionId: json["business_connection_id"],
    senderBusinessBot:
        _parseJson<User>(json["sender_business_bot"], User.fromJson),
    isFromOffline: json["is_from_offline"],
    chatBackgroundSet: _parseJson<ChatBackground>(
      json["chat_background_set"],
      ChatBackground.fromJson,
    ),
    effectId: json["effect_id"],
    showCaptionAboveMedia: json["show_caption_above_media"],
    paidMedia: _parseJson<PaidMediaInfo>(
      json['paid_media'],
      PaidMediaInfo.fromJson,
    ),
    refundedPayment: _parseJson<RefundedPayment>(
      json['refunded_payment'],
      RefundedPayment.fromJson,
    ),
  );
}