SproutContext class abstract

The build-time hook-dispatch handle passed to Sprout.build.

Extends TreeContext (throw-after-unmount inherited) with the hook surface. Hooks may only be called inside Sprout.build, unconditionally and in a stable order. A changed hook count or a type change at a position throws; a call outside build asserts; a same-shape reorder is undetectable (the positional-hooks caveat) — keep the order stable.

Implemented types

Constructors

SproutContext()

Properties

branchId → String
Stable id of the bound branch, issued by TreeOwner.issueId at mount.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
The Key of the bound branch's Seed config, or null if unkeyed.
no setterinherited
mounted → bool
Whether the bound branch is still mounted. Never throws — this is the safe staleness probe for handles held across async gaps.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

dependOnInheritedSeedOfExactType<T extends Object>({Object? aspect}) → T?
Returns the nearest ancestor value provided via InheritedSeed<T> of exact type T, registering the bound branch as a dependent; null when no such ancestor exists.
inherited
getInheritedSeedOfExactType<T extends Object>() → T?
Returns the nearest ancestor value provided via InheritedSeed<T> of exact type T without registering a dependency; null when no such ancestor exists.
inherited
markNeedsRebuild() → void
Marks the bound branch dirty for the next TreeOwner.flush.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
useEffect(Dispose? effect(), [List<Object?>? keys]) → void
Runs effect as a microtask-deferred passive effect. With keys omitted it runs after every build; const [] runs once (mount); a non-empty list re-runs when the keys change element-wise. effect may return a Dispose cleanup, run before the next re-run and on unmount.
useMemo<T>(T create(), List<Object?> keys) → T
Returns a value computed by create, recomputed only when keys change. Stabilizes derived identities (e.g. a stream) across rebuilds.
useState<T>(T initial) → StateCell<T>
Declares a persistent state StateCell seeded with initial on first build; later builds return the same cell (the new initial is ignored).
useStream<T>(Stream<T> source, {required T initial}) → T
Subscribes to source and returns its latest value (or initial before the first event). Re-subscribes only when the source changes (by ==, keeping the last value); cancels on unmount. Collapses Watch.

Operators

operator ==(Object other) → bool
The equality operator.
inherited