ChatMessageModel.fromJson constructor

ChatMessageModel.fromJson(
  1. Map jsonMap
)

Implementation

factory ChatMessageModel.fromJson(Map jsonMap) {
  InAppChat.instance.log("ChatMessageModel jsonMap" + jsonMap.toString());

  return ChatMessageModel(
    jsonMap["message"],
    createdAt: jsonMap["createdAt"] == null
        ? null
        : DateTime.tryParse(jsonMap["createdAt"]),
    read: toBool(jsonMap["read"]),
    seenAt: jsonMap["seenAt"] == null
        ? null
        : DateTime.tryParse(jsonMap["seenAt"]),
    status: messageStatusFromString[jsonMap['status']] ??
        ChatMessageStatus.unknown,
  )..id = jsonMap["id"];
}