prepareScan method
Prepare for a new scan cycle. Called once before the unified tree walk.
Override to clear accumulated state, issues, highlights, and initialise per-scan accumulators.
Implementation
@override
void prepareScan(BuildContext context) {
_highlights.clear();
_hotInstances.clear();
// Hot instances come from the held types, the same set the issues
// use, so the boxes don't blink while the cards stay. Only the
// instances that started the repaints are outlined, never other
// instances of the type that happen to be in the tree.
final snapshot = _pendingDebugSnapshot;
if (snapshot == null) return;
final seconds =
snapshot.elapsed.inMicroseconds / Duration.microsecondsPerSecond;
for (final MapEntry(key: type, value: held) in _perWidget.held.entries) {
final origins = snapshot.paintOrigins[type];
if (origins == null) continue;
for (final instance in origins.busiest) {
final element = instance.element;
if (element == null || !element.mounted) continue;
_hotInstances[element] = (
type: type,
rate: seconds > 0 ? instance.count / seconds : held.rate,
critical: held.critical,
);
}
}
}