fromJson method Null safety

Message fromJson(
  1. dynamic json
)

Implementation

static Message fromJson(dynamic json) {
  List<Answer> robotQaList = [];
  if (json['type'] == BytedeskConstants.MESSAGE_TYPE_ROBOT) {
    robotQaList = json['answers'] == null
        ? []
        : (json['answers'] as List<dynamic>)
            .map((item) => Answer.fromJson(item))
            .toList();
  }
  return Message(
      mid: json['mid'],
      content: json['content'],
      imageUrl: json['imageUrl'],
      voiceUrl: json['voiceUrl'],
      fileUrl: json['fileUrl'],
      videoUrl: json['videoOrShortUrl'],
      nickname: json['user']['nickname'],
      avatar: json['user']['avatar'],
      type: json['type'],
      timestamp: json['createdAt'],
      client: json['client'],
      answers: robotQaList,
      answersJson: json['answers'].toString());
}