fromJson static method

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'],
      // topic: json['thread']['topic'],
      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'],
      currentUid: SpUtil.getString(BytedeskConstants.uid),
      thread: Thread.fromUnreadJson(json['thread']),
      answers: robotQaList,
      answersJson: json['answers'].toString());
}