purgeExitingDuringThrottle method
void
purgeExitingDuringThrottle()
During a throttle-skip frame, drop sticky entries whose node just entered exiting state. Without this, a stale pinned row would keep painting / inflating paintExtent for another 1–2 frames until the next non-throttled recompute.
Implementation
void purgeExitingDuringThrottle() {
if (_stickyHeaders.isEmpty) return;
// Track removals so [_writtenStickyNids] stays in sync with
// [_stickyByNid] for the next recompute's clear loop.
final purgedNids = <int>{};
_stickyHeaders.removeWhere((s) {
if (_controller.isExiting(s.nodeId)) {
final nid = _controller.nidOf(s.nodeId);
if (nid >= 0 && nid < _stickyByNid.length) {
_stickyByNid[nid] = null;
purgedNids.add(nid);
}
return true;
}
return false;
});
if (purgedNids.isNotEmpty) {
// In-place compaction over the typed-data scratch buffer.
int writeIdx = 0;
for (int readIdx = 0; readIdx < _writtenStickyNidsLen; readIdx++) {
final nid = _writtenStickyNids[readIdx];
if (!purgedNids.contains(nid)) {
_writtenStickyNids[writeIdx++] = nid;
}
}
_writtenStickyNidsLen = writeIdx;
}
}