FlutterWidgetProperty.fromJson constructor
FlutterWidgetProperty.fromJson(
- JsonDecoder jsonDecoder,
- String jsonPath,
- Object? json
)
Implementation
factory FlutterWidgetProperty.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
json ??= {};
if (json is Map) {
String? documentation;
if (json.containsKey('documentation')) {
documentation = jsonDecoder.decodeString(
'$jsonPath.documentation', json['documentation']);
}
String? expression;
if (json.containsKey('expression')) {
expression = jsonDecoder.decodeString(
'$jsonPath.expression', json['expression']);
}
int id;
if (json.containsKey('id')) {
id = jsonDecoder.decodeInt('$jsonPath.id', json['id']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'id');
}
bool isRequired;
if (json.containsKey('isRequired')) {
isRequired =
jsonDecoder.decodeBool('$jsonPath.isRequired', json['isRequired']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'isRequired');
}
bool isSafeToUpdate;
if (json.containsKey('isSafeToUpdate')) {
isSafeToUpdate = jsonDecoder.decodeBool(
'$jsonPath.isSafeToUpdate', json['isSafeToUpdate']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'isSafeToUpdate');
}
String name;
if (json.containsKey('name')) {
name = jsonDecoder.decodeString('$jsonPath.name', json['name']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'name');
}
List<FlutterWidgetProperty>? children;
if (json.containsKey('children')) {
children = jsonDecoder.decodeList(
'$jsonPath.children',
json['children'],
(String jsonPath, Object? json) =>
FlutterWidgetProperty.fromJson(jsonDecoder, jsonPath, json));
}
FlutterWidgetPropertyEditor? editor;
if (json.containsKey('editor')) {
editor = FlutterWidgetPropertyEditor.fromJson(
jsonDecoder, '$jsonPath.editor', json['editor']);
}
FlutterWidgetPropertyValue? value;
if (json.containsKey('value')) {
value = FlutterWidgetPropertyValue.fromJson(
jsonDecoder, '$jsonPath.value', json['value']);
}
return FlutterWidgetProperty(id, isRequired, isSafeToUpdate, name,
documentation: documentation,
expression: expression,
children: children,
editor: editor,
value: value);
} else {
throw jsonDecoder.mismatch(jsonPath, 'FlutterWidgetProperty', json);
}
}