styles method

List<InspectStyle> styles()

style existed have only the old keys, and a ramp of the exceptions still beats an empty table when reopening an old run.

Implementation

List<InspectStyle> styles() {
  var buckets = <String, InspectStyle>{};
  for (var node in _onstage) {
    var properties = node.textStyle.isNotEmpty
        ? node.textStyle
        : node.properties;
    if (properties['size'] == null && properties['color'] == null) continue;
    // Text nodes only: a `size` on something that draws no words is a
    // different measurement wearing the same name.
    if (node.description?.contains('"') != true) continue;
    var style = InspectStyle(
      size: properties['size'],
      weight: properties['weight'],
      color: properties['color'],
      count: 1,
      sample: _words(node) ?? '',
    );
    var existing = buckets[style.key];
    buckets[style.key] = existing == null
        ? style
        : existing.plusOne(style.sample);
  }
  return buckets.values.toList()..sort((a, b) => b.count.compareTo(a.count));
}