fromJson static method
Returns a new QuestionConfig instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static QuestionConfig? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
assert(json.containsKey(r'_id'), 'Required key "QuestionConfig[_id]" is missing from JSON.');
assert(json[r'_id'] != null, 'Required key "QuestionConfig[_id]" has a null value in JSON.');
assert(json.containsKey(r'tenantId'), 'Required key "QuestionConfig[tenantId]" is missing from JSON.');
assert(json[r'tenantId'] != null, 'Required key "QuestionConfig[tenantId]" has a null value in JSON.');
assert(json.containsKey(r'name'), 'Required key "QuestionConfig[name]" is missing from JSON.');
assert(json[r'name'] != null, 'Required key "QuestionConfig[name]" has a null value in JSON.');
assert(json.containsKey(r'question'), 'Required key "QuestionConfig[question]" is missing from JSON.');
assert(json[r'question'] != null, 'Required key "QuestionConfig[question]" has a null value in JSON.');
assert(json.containsKey(r'helpText'), 'Required key "QuestionConfig[helpText]" is missing from JSON.');
assert(json[r'helpText'] != null, 'Required key "QuestionConfig[helpText]" has a null value in JSON.');
assert(json.containsKey(r'createdAt'), 'Required key "QuestionConfig[createdAt]" is missing from JSON.');
assert(json[r'createdAt'] != null, 'Required key "QuestionConfig[createdAt]" has a null value in JSON.');
assert(json.containsKey(r'createdBy'), 'Required key "QuestionConfig[createdBy]" is missing from JSON.');
assert(json[r'createdBy'] != null, 'Required key "QuestionConfig[createdBy]" has a null value in JSON.');
assert(json.containsKey(r'usedCount'), 'Required key "QuestionConfig[usedCount]" is missing from JSON.');
assert(json[r'usedCount'] != null, 'Required key "QuestionConfig[usedCount]" has a null value in JSON.');
assert(json.containsKey(r'lastUsed'), 'Required key "QuestionConfig[lastUsed]" is missing from JSON.');
assert(json[r'lastUsed'] != null, 'Required key "QuestionConfig[lastUsed]" has a null value in JSON.');
assert(json.containsKey(r'type'), 'Required key "QuestionConfig[type]" is missing from JSON.');
assert(json[r'type'] != null, 'Required key "QuestionConfig[type]" has a null value in JSON.');
assert(json.containsKey(r'numStars'), 'Required key "QuestionConfig[numStars]" is missing from JSON.');
assert(json[r'numStars'] != null, 'Required key "QuestionConfig[numStars]" has a null value in JSON.');
assert(json.containsKey(r'min'), 'Required key "QuestionConfig[min]" is missing from JSON.');
assert(json[r'min'] != null, 'Required key "QuestionConfig[min]" has a null value in JSON.');
assert(json.containsKey(r'max'), 'Required key "QuestionConfig[max]" is missing from JSON.');
assert(json[r'max'] != null, 'Required key "QuestionConfig[max]" has a null value in JSON.');
assert(json.containsKey(r'defaultValue'), 'Required key "QuestionConfig[defaultValue]" is missing from JSON.');
assert(json[r'defaultValue'] != null, 'Required key "QuestionConfig[defaultValue]" has a null value in JSON.');
assert(json.containsKey(r'labelNegative'), 'Required key "QuestionConfig[labelNegative]" is missing from JSON.');
assert(json[r'labelNegative'] != null, 'Required key "QuestionConfig[labelNegative]" has a null value in JSON.');
assert(json.containsKey(r'labelPositive'), 'Required key "QuestionConfig[labelPositive]" is missing from JSON.');
assert(json[r'labelPositive'] != null, 'Required key "QuestionConfig[labelPositive]" has a null value in JSON.');
assert(json.containsKey(r'customOptions'), 'Required key "QuestionConfig[customOptions]" is missing from JSON.');
assert(json[r'customOptions'] != null, 'Required key "QuestionConfig[customOptions]" has a null value in JSON.');
assert(json.containsKey(r'subQuestionIds'), 'Required key "QuestionConfig[subQuestionIds]" is missing from JSON.');
assert(json[r'subQuestionIds'] != null, 'Required key "QuestionConfig[subQuestionIds]" has a null value in JSON.');
assert(json.containsKey(r'alwaysShowSubQuestions'), 'Required key "QuestionConfig[alwaysShowSubQuestions]" is missing from JSON.');
assert(json[r'alwaysShowSubQuestions'] != null, 'Required key "QuestionConfig[alwaysShowSubQuestions]" has a null value in JSON.');
assert(json.containsKey(r'reportingOrder'), 'Required key "QuestionConfig[reportingOrder]" is missing from JSON.');
assert(json[r'reportingOrder'] != null, 'Required key "QuestionConfig[reportingOrder]" has a null value in JSON.');
return true;
}());
return QuestionConfig(
id: mapValueOfType<String>(json, r'_id')!,
tenantId: mapValueOfType<String>(json, r'tenantId')!,
name: mapValueOfType<String>(json, r'name')!,
question: mapValueOfType<String>(json, r'question')!,
summaryLabel: mapValueOfType<String>(json, r'summaryLabel'),
helpText: mapValueOfType<String>(json, r'helpText')!,
createdAt: mapDateTime(json, r'createdAt', r'')!,
createdBy: mapValueOfType<String>(json, r'createdBy')!,
usedCount: mapValueOfType<double>(json, r'usedCount')!,
lastUsed: mapDateTime(json, r'lastUsed', r'')!,
type: mapValueOfType<String>(json, r'type')!,
numStars: mapValueOfType<double>(json, r'numStars')!,
min: mapValueOfType<double>(json, r'min')!,
max: mapValueOfType<double>(json, r'max')!,
defaultValue: mapValueOfType<double>(json, r'defaultValue')!,
labelNegative: mapValueOfType<String>(json, r'labelNegative')!,
labelPositive: mapValueOfType<String>(json, r'labelPositive')!,
customOptions: QuestionConfigCustomOptionsInner.listFromJson(json[r'customOptions']),
subQuestionIds: json[r'subQuestionIds'] is Iterable
? (json[r'subQuestionIds'] as Iterable).cast<String>().toList(growable: false)
: const [],
alwaysShowSubQuestions: mapValueOfType<bool>(json, r'alwaysShowSubQuestions')!,
reportingOrder: mapValueOfType<double>(json, r'reportingOrder')!,
);
}
return null;
}