toJson method
Serializes to the JSON consumed by the MCP server and the site.
Implementation
Map<String, Object?> toJson() => <String, Object?>{
'id': id,
'name': name,
'category': category.name,
'status': status.name,
'summary': summary.toJson(),
if (description != null) 'description': description!.toJson(),
if (whenToUse.isNotEmpty) 'whenToUse': whenToUse.toJson(),
if (whenNotToUse.isNotEmpty) 'whenNotToUse': whenNotToUse.toJson(),
if (props.isNotEmpty)
'props': props.map((PropMeta p) => p.toJson()).toList(),
if (variants.isNotEmpty) 'variants': variants,
if (states.isNotEmpty) 'states': states,
if (examples.isNotEmpty)
'examples': examples.map((CodeExample e) => e.toJson()).toList(),
if (dos.isNotEmpty) 'do': dos.toJson(),
if (donts.isNotEmpty) 'dont': donts.toJson(),
if (a11y != null) 'a11y': a11y!.toJson(),
'crossPlatform': crossPlatform,
'themeAware': themeAware,
'reducesMotion': reducesMotion,
if (related.isNotEmpty) 'related': related,
};