toJson method

Map<String, Object?> toJson()

Implementation

Map<String, Object?> toJson() => {
  'id': id,
  'type': type,
  if (description != null) 'description': description,
  if (widgetKey != null) 'widgetKey': widgetKey,
  if (source != null) 'source': source!.toJson(),
  'local': createdByLocalProject,
  // Sparse: nearly every node is on stage, and the flag is only news when
  // it is true.
  if (offstage) 'offstage': true,
  if (properties.isNotEmpty) 'properties': properties,
  if (textStyle.isNotEmpty) 'style': textStyle,
  // `"same"` rather than the whole map again — see [_readInherited].
  if (inheritedStyle.isNotEmpty)
    'inherited': _sameAsResolved ? 'same' : inheritedStyle,
  if (styleReplacesInherited != null) 'styleReplaces': styleReplacesInherited,
  if (keys.isNotEmpty) 'keys': [for (var key in keys) key.toJson()],
  if (unkeyedText.isNotEmpty) 'unkeyed': unkeyedText,
  if (textOverflowed) 'overflowed': true,
  if (layout != null) 'layout': layout!.toJson(),
  if (label != null) 'label': label,
  if (selected != null) 'selected': selected,
  if (elidedChildren > 0) 'elided': elidedChildren,
  if (children.isNotEmpty)
    'children': [for (var child in children) child.toJson()],
};