toJson method Null safety

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() {
  final Map<String, dynamic> data = <String, dynamic>{};
  if (generalKnowledge != null) {
    data['GeneralKnowledge'] = generalKnowledge!.toJson();
  }
  if (art != null) {
    data['Art'] = art!.toJson();
  }
  if (entertainment != null) {
    data['Entertainment'] = entertainment!.toJson();
  }
  if (science != null) {
    data['Science'] = science!.toJson();
  }
  if (mythology != null) {
    data['Mythology'] = mythology!.toJson();
  }
  if (history != null) {
    data['History'] = history!.toJson();
  }
  if (sports != null) {
    data['Sports'] = sports!.toJson();
  }
  return data;
}