EMConversation.fromJson constructor

EMConversation.fromJson(
  1. Map<String, dynamic> map
)

Implementation

factory EMConversation.fromJson(Map<String, dynamic> map) {
  Map<String, String>? ext = map['ext']?.cast<String, String>();
  String? name;
  if (ext != null) {
    if (ext.containsKey("con_name")) {
      name = ext['con_name']!;
      ext.remove('con_name');
    }
  }

  EMConversation ret = EMConversation._private();
  ret.type = typeFromInt(map['type']);
  ret.id = map['con_id'];
  ret._unreadCount = map['unreadCount'];
  ret._ext = ext;
  ret._name = name ?? '';
  if (map['latestMessage'] != null) {
    ret._latestMessage = EMMessage.fromJson(map['latestMessage']);
  }
  if (map['lastReceivedMessage'] != null) {
    ret._lastReceivedMessage = EMMessage.fromJson(map['lastReceivedMessage']);
  }
  return ret;
}