ChatMessage.fromJson constructor

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

Implementation

factory ChatMessage.fromJson(Map<String, dynamic> map) {
  return ChatMessage._private()
    ..to = map["to"]
    ..from = map["from"]
    ..body = _bodyFromMap(map["body"])!
    ..attributes = map.getMapValue("attributes")
    ..direction = map["direction"] == 'send'
        ? MessageDirection.SEND
        : MessageDirection.RECEIVE
    ..hasRead = map.boolValue('hasRead')
    ..hasReadAck = map.boolValue('hasReadAck')
    ..needGroupAck = map.boolValue('needGroupAck')
    ..hasDeliverAck = map.boolValue('hasDeliverAck')
    .._msgId = map["msgId"]
    ..conversationId = map["conversationId"]
    ..chatType = chatTypeFromInt(map["chatType"])
    ..localTime = map["localTime"] ?? 0
    ..serverTime = map["serverTime"] ?? 0
    ..isChatThreadMessage = map["isThread"] ?? false
    ..onlineState = map["onlineState"] ?? true
    ..deliverOnlineOnly = map['deliverOnlineOnly'] ?? false
    ..status = messageStatusFromInt(map["status"])
    ..receiverList = map["receiverList"]?.cast<String>()
    ..isBroadcast = map["broadcast"] ?? false
    ..isContentReplaced = map["isContentReplaced"] ?? false;
}