StickyHeaderComputer<TKey, TData> class
Computes sticky headers and owns the scratch state required for the computation. The owning render object hands in the per-frame inputs (visible nodes, layout-space offsets and extents, scroll position) and reads back the computed headers / infoForNid for paint, hit-test, and transform.
The computer is layout-state-shaped: a single instance is long-lived per render object and mutated in place each layout. Reset it via reset when the underlying controller swaps.
Constructors
-
StickyHeaderComputer({required TreeController<
TKey, TData> controller, int maxStickyDepth = 0})
Properties
-
controller
↔ TreeController<
TKey, TData> -
getter/setter pair
- dirty ↔ bool
-
Whether sticky subtree precomputation needs to re-run. Set on
structure change, extent change, or animation-to-idle transition;
cleared by precomputeStableSubtreeBottoms.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ List<
StickyHeaderInfo< TKey> > -
All sticky headers in root→leaf order. The render object iterates
this from index 0 (shallowest, painted last so it lands on top).
no setter
- maxStickyDepth ↔ int
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
computeStickyHeaders(
{required double scrollOffset, required double overlap, required List< TKey> visibleNodes, required Float64List nodeOffsetsByNid, required Float64List nodeExtentsByNid, required FindFirstVisibleIndex findFirstVisibleIndex}) → void -
Computes sticky headers based on scroll position, populating
headers and the per-nid lookup. Called after Pass 2 when actual
extents and offsets are available.
overlapisconstraints.overlap— the number of pixels at the top covered by a preceding pinned sliver (e.g. PinnedHeaderSliver). -
identifyPotentialStickyNodes(
{required double scrollOffset, required double overlap, required List< TKey> visibleNodes, required Float64List nodeOffsetsByNid, required Float64List nodeExtentsByNid, required FindFirstVisibleIndex findFirstVisibleIndex}) → Set<TKey> - Lightweight pre-pass that identifies nodes which might need to be sticky. Used before Pass 2 to force-create their render objects.
-
infoForNid(
int nid) → StickyHeaderInfo< TKey> ? -
Sticky info for
nid, or null when the node is not currently sticky. Hot-path lookup used by paint transform and retention checks. -
invalidatePrecompute(
) → void - Forces the next layout to take the per-candidate fallback path instead of the precomputed-array path. Used during animation frames where the cached subtree bottoms are stale.
-
isSticky(
int nid) → bool -
Whether
nidis currently sticky. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
precomputeStableSubtreeBottoms(
{required List< TKey> visibleNodes, required Float64List nodeOffsetsByNid, required Float64List nodeExtentsByNid}) → void - Precomputes subtree bottom offsets for all visible nodes in O(N).
-
purgeExitingDuringThrottle(
) → void - 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.
-
reset(
) → void - Resets every piece of layout-derived state to the empty defaults the render object uses on first layout. Call when the controller swaps or the render object is hot-reloaded.
-
resizeForCapacity(
int nidCapacity) → void - Grows the nid-indexed sticky array to match the controller's current nid capacity. Called from the render object's layout-array growth path so all per-nid arrays stay in lockstep.
-
resizeScratchArrays(
int capacity) → void -
Pre-allocates scratch arrays for
capacitynodes. Useful when the tree size is known upfront to avoid incremental resizing. -
shouldRecomputeThisFrame(
{required bool hasActiveAnimations, required double scrollOffset}) → bool -
Returns true when sticky should be recomputed this frame. The
throttle keeps mid-animation frames cheap (every third frame) but
fires on every scroll, since stale
pinnedYvalues produce visible jitter and wrong hit-test coordinates. -
toString(
) → String -
A string representation of this object.
inherited
-
trimScratchArrays(
) → void -
Reallocates scratch arrays to fit
_lastPrecomputedCount(or empty if zero). Call when the tree shrinks significantly and memory matters.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited