ChatMessage.fromJson constructor

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

Creates a ChatMessage instance from a JSON map.

Implementation

factory ChatMessage.fromJson(Map<String, dynamic> json) => ChatMessage(
    chatUserJid: json["chatUserJid"] ?? "",
    contactType: getContactType(json),
    isItCarbonMessage: Platform.isAndroid
        ? json["isItCarbonMessage"] ?? false
        : json["isCarbonMessage"] ?? false,
    isItSavedContact: Platform.isAndroid
        ? json["isItSavedContact"] ?? false
        : json["isSavedContact"] ?? false,
    isMessageDeleted: json["isMessageDeleted"],
    isMessageRecalled: json["isMessageRecalled"],
    isMessageSentByMe: json["isMessageSentByMe"],
    isMessageStarred: json["isMessageStarred"],
    isSelected: json["isSelected"] ?? false,
    isThisAReplyMessage: Platform.isAndroid
        ? json["isThisAReplyMessage"]
        : json["isReplyMessage"],
    messageChatType:
        json["messageChatType"].toString().toLowerCase() == "singlechat"
            ? "chat"
            : json["messageChatType"].toLowerCase(),
    messageCustomField: json["messageCustomField"] ?? {},
    messageId: json["messageId"],
    messageSentTime: json["messageSentTime"].toInt(),
    messageStatus: getMessageStatus(Platform.isAndroid
        ? json["messageStatus"]["status"]
        : json["messageStatus"]),
    isMessageEdited:
        Platform.isAndroid ? json["isEdited"] : json["isMessageEdited"],
    messageTextContent: json["messageTextContent"].toString(),
    messageType: getMessageType(json["messageType"]),
    metaData: json["metaData"] == null
        ? []
        : List<MessageMetaData>.from(
            json["metaData"].map((x) => MessageMetaData.fromJson(x))),
    replyParentChatMessage: json["replyParentChatMessage"] == null
        ? null
        : ReplyParentChatMessage.fromJson(json["replyParentChatMessage"]),
    senderNickName: json["senderNickName"],
    senderUserJid: json["senderUserJid"],
    senderUserName: json["senderUserName"],
    contactChatMessage: json["contactChatMessage"] == null
        ? null
        : ContactChatMessage.fromJson(json["contactChatMessage"]),
    mediaChatMessage: json["mediaChatMessage"] == null
        ? null
        : MediaChatMessage.fromJson(json["mediaChatMessage"]),
    locationChatMessage: json["locationChatMessage"] == null
        ? null
        : LocationChatMessage.fromJson(json["locationChatMessage"]),
    topicId: Platform.isIOS ? json["topicID"] : json["topicId"]);