ChatModel.fromJson constructor

ChatModel.fromJson(
  1. Map jsonMap
)

Implementation

factory ChatModel.fromJson(Map jsonMap) {
  InAppChat.instance.log("ChatModel jsonMap" + jsonMap.toString());
  return ChatModel(
    userId: jsonMap["userId"],
    peerId: jsonMap["peerId"],
    peerName: jsonMap["peerName"],
    peerOnline: toBool(jsonMap["peerOnline"]),
    lastModified: jsonMap["lastModified"] == null
        ? null
        : DateTime.tryParse(
            jsonMap["lastModified"],
          ),
    mostRecentMessageId: jsonMap["mostRecentMessageId"],
    createdAt: jsonMap["createdAt"] == null
        ? null
        : DateTime.tryParse(jsonMap["createdAt"]),
  )..id = jsonMap["id"];
}