fromJson static method
Returns a new FormLayoutData instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static FormLayoutData? fromJson(dynamic value) {
if (value is FormLayoutData) {
return 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(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key), 'Required key "FormLayoutData[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "FormLayoutData[$key]" has a null value in JSON.');
});
return true;
}());
return FormLayoutData(
subForm: mapValueOfType<bool>(json, r'subForm'),
irrelevant: mapValueOfType<bool>(json, r'irrelevant'),
determinesSscontactName: mapValueOfType<bool>(json, r'determinesSscontactName'),
type: mapValueOfType<String>(json, r'type'),
name: mapValueOfType<String>(json, r'name'),
sortOrder: mapValueOfType<double>(json, r'sortOrder'),
options: mapValueOfType<Map<String, FormDataOption>>(json, r'options') ?? const {},
descr: mapValueOfType<String>(json, r'descr'),
label: mapValueOfType<String>(json, r'label'),
editor: Editor.fromJson(json[r'editor']),
defaultValue: ContentDto.listFromJson(json[r'defaultValue']) ?? const [],
defaultStatus: mapValueOfType<int>(json, r'defaultStatus'),
suggest: Suggest.listFromJson(json[r'suggest']) ?? const [],
plannings: FormPlanning.listFromJson(json[r'plannings']) ?? const [],
tags: GuiCode.listFromJson(json[r'tags']) ?? const [],
codes: GuiCode.listFromJson(json[r'codes']) ?? const [],
codeTypes: GuiCodeType.listFromJson(json[r'codeTypes']) ?? const [],
formulas: Formula.listFromJson(json[r'formulas']) ?? const [],
);
}
return null;
}