Message.fromJson constructor

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

Implementation

factory Message.fromJson(Map<String, dynamic> json) {
  return Message(
    id: json["id"] == null
        ? null
        : (json["id"] is Map
            ? MessageId.fromJson(Map<String, dynamic>.from(json["id"]))
            : MessageId(
                fromMe: false,
                remote: "",
                id: "",
                serialized: json["id"].toString())),
    body: json["body"]?.toString() ?? "",
    type: json["type"]?.toString() ?? "",
    t: json["t"] is int ? json["t"] : (int.tryParse(json["t"]?.toString() ?? "0") ?? 0),
    notifyName: json["notifyName"]?.toString() ?? "",
    from: json["from"]?.toString() ?? "",
    to: json["to"]?.toString() ?? "",
    self: json["self"]?.toString() ?? "",
    isNewMsg: json["isNewMsg"] == true || json["isNewMsg"]?.toString() == "true",
    star: json["star"] == true || json["star"]?.toString() == "true",
    kicNotified: json["kicNotified"] == true || json["kicNotified"]?.toString() == "true",
    recvFresh: json["recvFresh"] == true || json["recvFresh"]?.toString() == "true",
    isFromTemplate: json["isFromTemplate"] == true || json["isFromTemplate"]?.toString() == "true",
    pollInvalidated: json["pollInvalidated"] == true || json["pollInvalidated"]?.toString() == "true",
    broadcast: json["broadcast"] == true || json["broadcast"]?.toString() == "true",
    isForwarded: json["isForwarded"] == true || json["isForwarded"]?.toString() == "true",
    hasReaction: json["hasReaction"] == true || json["hasReaction"]?.toString() == "true",
    ephemeralOutOfSync: json["ephemeralOutOfSync"] == true || json["ephemeralOutOfSync"]?.toString() == "true",
    productHeaderImageRejected: json["productHeaderImageRejected"] == true || json["productHeaderImageRejected"]?.toString() == "true",
    lastPlaybackProgress: json["lastPlaybackProgress"] is int ? json["lastPlaybackProgress"] : (int.tryParse(json["lastPlaybackProgress"]?.toString() ?? "0") ?? 0),
    isDynamicReplyButtonsMsg: json["isDynamicReplyButtonsMsg"] == true || json["isDynamicReplyButtonsMsg"]?.toString() == "true",
    isMdHistoryMsg: json["isMdHistoryMsg"] == true || json["isMdHistoryMsg"]?.toString() == "true",
    stickerSentTs: json["stickerSentTs"] is int ? json["stickerSentTs"] : (int.tryParse(json["stickerSentTs"]?.toString() ?? "0") ?? 0),
    requiresDirectConnection: json["requiresDirectConnection"] == true || json["requiresDirectConnection"]?.toString() == "true",
    pttForwardedFeaturesEnabled: json["pttForwardedFeaturesEnabled"] == true || json["pttForwardedFeaturesEnabled"]?.toString() == "true",
    caption: json["caption"]?.toString() ?? "",
  );
}