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> -
The controller the probe reads structure, depths and extents from.
Re-bindable so one computer survives a controller swap; assigning the
same instance is a no-op. Pair a real swap with reset, which drops
state keyed to the old controller's nids.
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-to-leaf order. The render object iterates
this from index 0 (shallowest, painted last so it lands on top).
no setter
- maxStickyDepth ↔ int
-
How many ancestor levels may pin at once. Zero disables sticky
headers entirely, and is the candidate probe's first early-out.
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, double freshOffsetAt(int visibleIndex)?}) → Set<TKey> - Computes the sticky set for this layout, populating headers and the per-nid lookup, and returns the candidate keys so the caller can force-create any that are outside the cache region.
-
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).
-
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. -
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