fromMap static method

Message fromMap(
  1. Map map
)

Implementation

static Message fromMap(Map map) {
  Map conversationMap = map["conversation"];
  Conversation conversation = Conversation.fromMap(conversationMap);
  Message m = Message(conversation);
  m.contentType = map['contentType'] ?? '';
  m.clientMsgNo = map['clientMsgNo'] ?? -1;
  m.messageId = map['messageId'] ?? '';
  m.direction = map['direction'] ?? 0;
  m.messageState = map['messageState'] ?? 0;
  m.hasRead = map['hasRead'] ?? false;
  m.timestamp = map['timestamp'] ?? 0;
  m.senderUserId = map['senderUserId'] ?? '';
  String? contentString = map["content"];
  if (contentString != null) {
    m.content = ContentTypeCenter.getContent(m.contentType, contentString);
  }
  Map? groupReadInfoMap = map['groupReadInfo'];
  if (groupReadInfoMap != null) {
    m.groupReadInfo = GroupMessageReadInfo.fromMap(groupReadInfoMap);
  }
  Map? mentionInfoMap = map['mentionInfo'];
  if (mentionInfoMap != null) {
    m.mentionInfo = MessageMentionInfo.fromMap(mentionInfoMap);
  }
  if (map['referredMsg'] != null) {
    m.referredMsg = Message.fromMap(map['referredMsg']);
  }
  m.localAttribute = map['localAttribute'] ?? '';
  m.isEdit = map['isEdit'] ?? false;
  if (map['sender'] != null) {
    m.sender = UserInfo.fromMap(map['sender']);
  }
  m.destroyTime = map['destroyTime'] ?? 0;
  m.lifeTimeAfterRead = map['lifeTimeAfterRead'] ?? 0;

  return m;
}