JMConversationInfo.fromJson constructor Null safety

JMConversationInfo.fromJson(
  1. Map json
)

Implementation

JMConversationInfo.fromJson(Map<dynamic, dynamic> json)
    : conversationType = getEnumFromString(
          JMConversationType.values, json['conversationType']),
      title = json['title'],
      unreadCount = json['unreadCount'],
      extras = json['extras'] {
  switch (conversationType) {
    case JMConversationType.single:
      target = JMUserInfo.fromJson(json['target']);
      break;
    case JMConversationType.group:
      target = JMGroupInfo.fromJson(json['target']);
      break;
    case JMConversationType.chatRoom:
      target = JMChatRoomInfo.fromJson(json['target']);
      break;
  }

  latestMessage =
      JMNormalMessage.generateMessageFromJson(json['latestMessage']);
}