in tool/catalog/generate_widget_catalog.dart [110:156]
Map<String, Object> _convertToJson(
ClassElement classElement,
ClassElement widgetClass,
) {
// flutter/src/material/about.dart
final String filePath = classElement.library.librarySource.uri.path;
final String libraryName = filePath.split('/')[2];
String summary;
final ElementAnnotation summaryAnnotation =
_getAnnotations(classElement, 'Summary')
.firstWhere((_) => true, orElse: () => null);
if (summaryAnnotation != null) {
final DartObject text =
summaryAnnotation.computeConstantValue().getField('text');
summary = text.toStringValue().trim();
}
List<String> categories;
final ElementAnnotation categoryAnnotation =
_getAnnotations(classElement, 'Category')
.firstWhere((_) => true, orElse: () => null);
if (categoryAnnotation != null) {
final DartObject value =
categoryAnnotation.computeConstantValue().getField('sections');
categories = value
.toListValue()
.map((DartObject obj) => obj.toStringValue())
.toList();
}
final Map<String, Object> m = <String, Object>{};
m['name'] = classElement.name;
if (classElement != widgetClass) {
m['parent'] = classElement.supertype.element.name;
}
m['library'] = libraryName;
if (classElement.isAbstract) {
m['abstract'] = true;
}
if (categories != null) {
m['categories'] = categories;
}
m['description'] = summary ?? _singleLine(classElement.documentationComment);
return m;
}