fromJson static method
Returns a new InputField instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static InputField? 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'name'), 'Required key "InputField[name]" is missing from JSON.');
assert(json[r'name'] != null, 'Required key "InputField[name]" has a null value in JSON.');
assert(json.containsKey(r'type'), 'Required key "InputField[type]" is missing from JSON.');
assert(json[r'type'] != null, 'Required key "InputField[type]" has a null value in JSON.');
assert(json.containsKey(r'required'), 'Required key "InputField[required]" is missing from JSON.');
assert(json[r'required'] != null, 'Required key "InputField[required]" has a null value in JSON.');
assert(json.containsKey(r'description'), 'Required key "InputField[description]" is missing from JSON.');
return true;
}());
return InputField(
name: mapValueOfType<String>(json, r'name')!,
type: InputFieldTypeEnum.fromJson(json[r'type'])!,
required_: mapValueOfType<bool>(json, r'required')!,
description: mapValueOfType<String>(json, r'description'),
fields: InputField.listFromJson(json[r'fields']),
);
}
return null;
}