debugFillProperties method

  1. @override
void debugFillProperties(
  1. DiagnosticPropertiesBuilder properties,
  2. {String prefix = ''}
)
override

Adds all properties prefixing property names with the optional prefix.

Implementation

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties, { String prefix = '' }) {
  super.debugFillProperties(properties);
  if (debugLabel != null) {
    properties.add(MessageProperty('${prefix}debugLabel', debugLabel!));
  }
  final List<DiagnosticsNode> styles = <DiagnosticsNode>[
    ColorProperty('${prefix}color', color, defaultValue: null),
    ColorProperty('${prefix}backgroundColor', backgroundColor, defaultValue: null),
    StringProperty('${prefix}family', fontFamily, defaultValue: null, quoted: false),
    IterableProperty<String>('${prefix}familyFallback', fontFamilyFallback, defaultValue: null),
    DoubleProperty('${prefix}size', fontSize, defaultValue: null),
  ];
  String? weightDescription;
  if (fontWeight != null) {
    weightDescription = '${fontWeight!.index + 1}00';
  }
  // TODO(jacobr): switch this to use enumProperty which will either cause the
  // weight description to change to w600 from 600 or require existing
  // enumProperty to handle this special case.
  styles.add(DiagnosticsProperty<FontWeight>(
    '${prefix}weight',
    fontWeight,
    description: weightDescription,
    defaultValue: null,
  ));
  styles.add(EnumProperty<FontStyle>('${prefix}style', fontStyle, defaultValue: null));
  styles.add(DoubleProperty('${prefix}letterSpacing', letterSpacing, defaultValue: null));
  styles.add(DoubleProperty('${prefix}wordSpacing', wordSpacing, defaultValue: null));
  styles.add(EnumProperty<TextBaseline>('${prefix}baseline', textBaseline, defaultValue: null));
  styles.add(DoubleProperty('${prefix}height', height, unit: 'x', defaultValue: null));
  styles.add(EnumProperty<TextLeadingDistribution>('${prefix}leadingDistribution', leadingDistribution, defaultValue: null));
  styles.add(DiagnosticsProperty<Locale>('${prefix}locale', locale, defaultValue: null));
  styles.add(DiagnosticsProperty<Paint>('${prefix}foreground', foreground, defaultValue: null));
  styles.add(DiagnosticsProperty<Paint>('${prefix}background', background, defaultValue: null));
  if (decoration != null || decorationColor != null || decorationStyle != null || decorationThickness != null) {
    final List<String> decorationDescription = <String>[];
    if (decorationStyle != null) {
      decorationDescription.add(decorationStyle!.name);
    }

    // Hide decorationColor from the default text view as it is shown in the
    // terse decoration summary as well.
    styles.add(ColorProperty('${prefix}decorationColor', decorationColor, defaultValue: null, level: DiagnosticLevel.fine));

    if (decorationColor != null) {
      decorationDescription.add('$decorationColor');
    }

    // Intentionally collide with the property 'decoration' added below.
    // Tools that show hidden properties could choose the first property
    // matching the name to disambiguate.
    styles.add(DiagnosticsProperty<TextDecoration>('${prefix}decoration', decoration, defaultValue: null, level: DiagnosticLevel.hidden));
    if (decoration != null) {
      decorationDescription.add('$decoration');
    }
    assert(decorationDescription.isNotEmpty);
    styles.add(MessageProperty('${prefix}decoration', decorationDescription.join(' ')));
    styles.add(DoubleProperty('${prefix}decorationThickness', decorationThickness, unit: 'x', defaultValue: null));
  }

  final bool styleSpecified = styles.any((DiagnosticsNode n) => !n.isFiltered(DiagnosticLevel.info));
  properties.add(DiagnosticsProperty<bool>('${prefix}inherit', inherit, level: (!styleSpecified && inherit) ? DiagnosticLevel.fine : DiagnosticLevel.info));
  styles.forEach(properties.add);

  if (!styleSpecified) {
    properties.add(FlagProperty('inherit', value: inherit, ifTrue: '$prefix<all styles inherited>', ifFalse: '$prefix<no style specified>'));
  }

  styles.add(EnumProperty<TextOverflow>('${prefix}overflow', overflow, defaultValue: null));
}