in packages/devtools_app/lib/src/inspector/diagnostics.dart [169:332]
Widget build(BuildContext context) {
if (diagnostic == null) {
return const SizedBox();
}
final theme = Theme.of(context);
final colorScheme = theme.colorScheme;
final icon = diagnostic.icon;
final children = <Widget>[];
if (icon != null) {
children.add(_paddedIcon(icon));
}
final String name = diagnostic.name;
final defaultStyle = DefaultTextStyle.of(context).style;
final baseStyle = style ?? defaultStyle;
TextStyle textStyle =
baseStyle.merge(textStyleForLevel(diagnostic.level, colorScheme));
var descriptionTextStyle = textStyle;
// TODO(jacobr): use TextSpans and SelectableText instead of Text.
if (diagnostic.isProperty) {
// Display of inline properties.
final String propertyType = diagnostic.propertyType;
final Map<String, Object> properties = diagnostic.valuePropertiesJson;
if (name?.isNotEmpty == true && diagnostic.showName) {
children.add(Text('$name${diagnostic.separator} ', style: textStyle));
// provide some contrast between the name and description if both are
// present.
descriptionTextStyle =
descriptionTextStyle.merge(theme.subtleTextStyle);
}
if (diagnostic.isCreatedByLocalProject) {
textStyle = textStyle.merge(inspector_text_styles.regularBold);
}
String description = diagnostic.description;
if (propertyType != null && properties != null) {
switch (propertyType) {
case 'Color':
{
final int alpha = JsonUtils.getIntMember(properties, 'alpha');
final int red = JsonUtils.getIntMember(properties, 'red');
final int green = JsonUtils.getIntMember(properties, 'green');
final int blue = JsonUtils.getIntMember(properties, 'blue');
String radix(int chan) => chan.toRadixString(16).padLeft(2, '0');
if (alpha == 255) {
description = '#${radix(red)}${radix(green)}${radix(blue)}';
} else {
description =
'#${radix(alpha)}${radix(red)}${radix(green)}${radix(blue)}';
}
final Color color = Color.fromARGB(alpha, red, green, blue);
children.add(_paddedIcon(_colorIconMaker.getCustomIcon(color)));
break;
}
case 'IconData':
{
final int codePoint =
JsonUtils.getIntMember(properties, 'codePoint');
if (codePoint > 0) {
final icon = FlutterMaterialIcons.getIconForCodePoint(
codePoint,
colorScheme,
);
if (icon != null) {
children.add(_paddedIcon(icon));
}
}
break;
}
}
}
if (_showRenderObjectPropertiesAsLinks &&
propertyType == 'RenderObject') {
textStyle = textStyle..merge(inspector_text_styles.link(colorScheme));
}
// TODO(jacobr): custom display for units, iterables, and padding.
children.add(Flexible(
child: buildDescription(
description,
descriptionTextStyle,
context,
colorScheme,
isProperty: true,
),
));
if (diagnostic.level == DiagnosticLevel.fine &&
diagnostic.hasDefaultValue) {
children.add(const Text(' '));
children.add(_paddedIcon(defaultIcon));
}
} else {
// Non property, regular node case.
if (name?.isNotEmpty == true && diagnostic.showName && name != 'child') {
if (name.startsWith('child ')) {
children.add(Text(
name,
style: inspector_text_styles.unimportant(colorScheme),
));
} else {
children.add(Text(name, style: textStyle));
}
if (diagnostic.showSeparator) {
children.add(Text(
diagnostic.separator,
style: textStyle,
));
if (diagnostic.separator != ' ' &&
(diagnostic.description?.isNotEmpty ?? false)) {
children.add(Text(
' ',
style: textStyle,
));
}
}
}
if (!diagnostic.isSummaryTree && diagnostic.isCreatedByLocalProject) {
textStyle = textStyle.merge(inspector_text_styles.regularBold);
}
var diagnosticDescription = buildDescription(
diagnostic.description,
descriptionTextStyle,
context,
colorScheme,
isProperty: false,
);
if (errorText != null) {
// TODO(dantup): Find if there's a way to achieve this without
// the nested row.
diagnosticDescription = Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
diagnosticDescription,
_buildErrorText(colorScheme),
],
);
} else if (multiline &&
diagnostic.hasCreationLocation &&
!diagnostic.isProperty) {
diagnosticDescription = Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
diagnosticDescription,
_buildLocation(context),
],
);
}
children.add(Expanded(child: diagnosticDescription));
}
return Row(mainAxisSize: MainAxisSize.min, children: children);
}