QuizQuestionModel.fromJson constructor

QuizQuestionModel.fromJson(
  1. Map<String, dynamic> json
)

Implementation

QuizQuestionModel.fromJson(Map<String, dynamic> json) {
  try {
    type = json['type'];
    questionKey = json['questionKey'];
    label = json['label'] ?? '';
    shortLabel = json['shortLabel'];
    enabled = json['enabled'] ?? true;
    internal = json['internal'] ?? false;
    value = json['value'];
    options = json['options'] != null ? [...json['options'].map((e) => QuizOptionModel.fromJson(e))] : null;
    displayCondition = json['displayCondition'] != null ? DisplayConditionModel.fromJson(json['displayCondition']) : null;

    params = Params();
    params = json['params'] is Map ? Params.fromJson(json['params']) : Params();

    whyFalse = json['whyFalse'];
    whyTrue = json['whyTrue'];
    whyConfig = json['why'] != null ? WhyConfig.fromJson(json['why']) : null;
    whyConfig = affectFinalWhyConfig();
    other = json['other'] != null ? OtherOptionConfig.fromJson(json['other']) : null;
  } catch (e) {
    if (kDebugMode) {
      print('❌ Error on QuizQuestionModel.fromJson: $e');
      print('json causing error: $json');
    }
  }
}