generateMessageFromJson method Null safety

dynamic generateMessageFromJson(
  1. Map? json
)

Implementation

static dynamic generateMessageFromJson(Map<dynamic, dynamic>? json) {
  if (json == null) return null;

  JMMessageType type = getEnumFromString(JMMessageType.values, json['type']);
  switch (type) {
    case JMMessageType.text:
      return JMTextMessage.fromJson(json);
    case JMMessageType.image:
      return JMImageMessage.fromJson(json);
    case JMMessageType.voice:
      return JMVoiceMessage.fromJson(json);
    case JMMessageType.location:
      return JMLocationMessage.fromJson(json);
    case JMMessageType.file:
      return JMFileMessage.fromJson(json);
    case JMMessageType.custom:
      return JMCustomMessage.fromJson(json);
    case JMMessageType.event:
      return JMEventMessage.fromJson(json);
    case JMMessageType.prompt:
      return JMPromptMessage.fromJson(json);
    case JMMessageType.video:
      return JMPromptMessage.fromJson(json);
  }
}