Message.fromJson constructor

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

Parse from a json

Implementation

factory Message.fromJson(Map<String, dynamic> json) => Message(
      id: json['id'],
      senderId: MessageSender.fromJson(json['sender_id']),
      chatId: json['chat_id'],
      sendingState: json['sending_state'] == null
          ? null
          : MessageSendingState.fromJson(json['sending_state']),
      schedulingState: json['scheduling_state'] == null
          ? null
          : MessageSchedulingState.fromJson(json['scheduling_state']),
      isOutgoing: json['is_outgoing'],
      isPinned: json['is_pinned'],
      canBeEdited: json['can_be_edited'],
      canBeForwarded: json['can_be_forwarded'],
      canBeSaved: json['can_be_saved'],
      canBeDeletedOnlyForSelf: json['can_be_deleted_only_for_self'],
      canBeDeletedForAllUsers: json['can_be_deleted_for_all_users'],
      canGetAddedReactions: json['can_get_added_reactions'],
      canGetStatistics: json['can_get_statistics'],
      canGetMessageThread: json['can_get_message_thread'],
      canGetViewers: json['can_get_viewers'],
      canGetMediaTimestampLinks: json['can_get_media_timestamp_links'],
      canReportReactions: json['can_report_reactions'],
      hasTimestampedMedia: json['has_timestamped_media'],
      isChannelPost: json['is_channel_post'],
      isTopicMessage: json['is_topic_message'],
      containsUnreadMention: json['contains_unread_mention'],
      date: json['date'],
      editDate: json['edit_date'],
      forwardInfo: json['forward_info'] == null
          ? null
          : MessageForwardInfo.fromJson(json['forward_info']),
      interactionInfo: json['interaction_info'] == null
          ? null
          : MessageInteractionInfo.fromJson(json['interaction_info']),
      unreadReactions: List<UnreadReaction>.from(
          (json['unread_reactions'] ?? [])
              .map((item) => UnreadReaction.fromJson(item))
              .toList()),
      replyTo: json['reply_to'] == null
          ? null
          : MessageReplyTo.fromJson(json['reply_to']),
      messageThreadId: json['message_thread_id'],
      selfDestructTime: json['self_destruct_time'] ?? 0,
      selfDestructIn: json['self_destruct_in'],
      autoDeleteIn: json['auto_delete_in'],
      viaBotUserId: json['via_bot_user_id'],
      authorSignature: json['author_signature'],
      mediaAlbumId: int.parse(json['media_album_id']),
      restrictionReason: json['restriction_reason'],
      content: MessageContent.fromJson(json['content']),
      replyMarkup: json['reply_markup'] == null
          ? null
          : ReplyMarkup.fromJson(json['reply_markup']),
      extra: json['@extra'],
      clientId: json['@client_id'],
    );