InspectNode.fromJson constructor
Implementation
factory InspectNode.fromJson(Map<String, Object?> json) {
var textStyle = switch (json['style']) {
Map style => style.cast<String, String>(),
_ => const <String, String>{},
};
return InspectNode(
id: json['id'] as String? ?? '',
type: json['type'] as String? ?? '',
description: json['description'] as String?,
widgetKey: json['widgetKey'] as String?,
createdByLocalProject: json['local'] as bool? ?? false,
offstage: json['offstage'] as bool? ?? false,
elidedChildren: json['elided'] as int? ?? 0,
label: json['label'] as String?,
selected: json['selected'] as bool?,
properties: switch (json['properties']) {
Map properties => properties.cast<String, String>(),
_ => const {},
},
textStyle: textStyle,
inheritedStyle: _readInherited(json['inherited'], textStyle),
styleReplacesInherited: json['styleReplaces'] as bool?,
keys: [
for (var key in json['keys'] as List? ?? const [])
InspectKey.fromJson((key as Map).cast<String, Object?>()),
],
unkeyedText: [
for (var text in json['unkeyed'] as List? ?? const []) '$text',
],
textOverflowed: json['overflowed'] as bool? ?? false,
layout: switch (json['layout']) {
Map layout => InspectLayout.fromJson(layout.cast<String, Object?>()),
_ => null,
},
source: switch (json['source']) {
Map<String, Object?> source => InspectSource.fromJson(source),
Map source => InspectSource.fromJson(source.cast<String, Object?>()),
_ => null,
},
children: [
for (var child in json['children'] as List? ?? const [])
InspectNode.fromJson((child as Map).cast<String, Object?>()),
],
);
}