EMChatThread.fromJson constructor

EMChatThread.fromJson(
  1. Map map
)

Implementation

factory EMChatThread.fromJson(Map map) {
  String threadId = map["threadId"];
  String owner = map["owner"];
  String messageId = map["msgId"];
  String parentId = map["parentId"];
  int memberCount = map["memberCount"] as int;
  int messageCount = map["messageCount"] as int;
  int createAt = map["createAt"] as int;
  EMMessage? msg;
  if (map.containsKey("lastMessage")) {
    msg = EMMessage.fromJson(map["lastMessage"]);
  }
  String? threadName;
  if (map.containsKey("threadName")) {
    threadName = map["threadName"];
  }

  return EMChatThread._private(
    threadId: threadId,
    owner: owner,
    messageId: messageId,
    parentId: parentId,
    membersCount: memberCount,
    messageCount: messageCount,
    createAt: createAt,
    lastMessage: msg,
    threadName: threadName,
  );
}