RecentChat.fromJson constructor

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

Creates a RecentChat object from a JSON map.

Implementation

factory RecentChat.fromJson(Map<String, dynamic> json) => RecentChat(
      contactType: getContactType(json),
      isAdminBlocked: Platform.isAndroid
          ? json["isAdminBlocked"]
          : json["isBlockedByAdmin"],
      isBlocked: json["isBlocked"],
      isBlockedMe: json["isBlockedMe"],
      isBroadCast: json["isBroadCast"],
      isChatArchived: json["isChatArchived"],
      isPrivateChat:
          Platform.isAndroid ? json["isChatLocked"] : json["isPrivateChat"],
      isChatPinned: json["isChatPinned"],
      isConversationUnRead: json["isConversationUnRead"],
      isGroup: json["isGroup"],
      isGroupInOfflineMode: json["isGroupInOfflineMode"],
      isItSavedContact: json["isItSavedContact"],
      isLastMessageRecalledByUser: json["isLastMessageRecalledByUser"],
      isLastMessageSentByMe: json["isLastMessageSentByMe"],
      isMuted: json["isMuted"],
      isSelected: json["isSelected"],
      jid: json["jid"],
      lastMessageContent: json["lastMessageContent"],
      lastMessageId: json["lastMessageId"],
      lastMessageStatus: getLastMessageStatus(json["lastMessageStatus"]),
      lastMessageTime: json["lastMessageTime"].toInt().toString().length == 13
          ? json["lastMessageTime"] * 1000
          : json["lastMessageTime"],
      lastMessageType: getMessageType(json["lastMessageType"]),
      nickName: json["nickName"],
      profileImage: json["profileImage"],
      profileName: json["profileName"],
      unreadMessageCount: json["unreadMessageCount"],
      topicId: Platform.isAndroid ? json["topicId"] : json["topicID"],
      metaData: json["metaData"] == null
          ? []
          : List<MessageMetaData>.from(
              json["metaData"].map((x) => MessageMetaData.fromJson(x))),
    );