EMMessage.fromJson constructor

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

Implementation

factory EMMessage.fromJson(Map<String, dynamic> map) {
  return EMMessage._private()
    ..to = map['to'] as String?
    ..from = map['from'] as String?
    ..body = _bodyFromMap(map['body'])
    ..attributes = map['attributes'] ?? {}
    ..direction = map['direction'] == 'send'
        ? EMMessageDirection.SEND
        : EMMessageDirection.RECEIVE
    ..hasRead = map.boolValue('hasRead')
    ..hasReadAck = map.boolValue('hasReadAck')
    ..hasDeliverAck = map.boolValue('hasDeliverAck')
    .._msgId = map['msgId'] as String?
    ..conversationId = map['conversationId'] as String?
    ..chatType = chatTypeFromInt(map['chatType'] as int?)
    ..localTime = map['localTime'] as int?
    ..serverTime = map['serverTime'] as int?
    ..status = _chatStatusFromInt(map['status'] as int?);
}