findingCounts property

Map<ComparedState, int> get findingCounts

Findings across both halves, worst first — the header's chips.

Counted rather than built, for the same reason ok is scanned: the exported page reads this from inside a build, and findings allocates a row per finding and sorts them. A number does not need either.

Implementation

Map<ComparedState, int> get findingCounts {
  var counts = <ComparedState, int>{};
  for (var state in [
    for (var item in previewItems) item.state,
    for (var scenario in scenarios) scenario.state,
  ]) {
    if (isComparedFinding(state)) {
      counts[state] = (counts[state] ?? 0) + 1;
    }
  }
  return Map.fromEntries(
    counts.entries.toList()
      ..sort((a, b) => a.key.index.compareTo(b.key.index)),
  );
}