toJson method Null safety

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() {
  final Map<String, dynamic> data = <String, dynamic>{};
  if (durationInformation != null) {
    data['durationInformation'] = durationInformation!.toJson();
  }
  if (difficultyInformation != null) {
    data['difficultyInformation'] = difficultyInformation!.toJson();
  }
  data['minutesPlayed'] = minutesPlayed;
  data['questionsAnswered'] = questionsAnswered;
  data['elo'] = elo;
  data['questionsRightAnswered'] = questionsRightAnswered;
  if (categoryInformation != null) {
    data['categoryInformation'] = categoryInformation!.toJson();
  }
  data['username'] = username;
  return data;
}