TreeSnapshot<TKey, TItem> class
Immutable normalized tree structure consumed by SyncedSliverTree.
roots defines root order, dataByKey stores payloads, and childrenByParent stores sibling order for each parent.
Constructors
-
TreeSnapshot({required Iterable<
TKey> roots, required Map<TKey, TItem> dataByKey, Map<TKey, Iterable< ? childrenByParent})TKey> > -
TreeSnapshot.fromFlat({required Iterable<
TItem> items, required TKey keyOf(TItem item), required TKey? parentOf(TItem item)}) -
Builds a validated snapshot from flat items with optional parent keys.
factory
-
TreeSnapshot.fromHierarchy({required Iterable<
TItem> roots, required TKey keyOf(TItem item), required Iterable<TItem> childrenOf(TItem item)}) -
Builds a validated snapshot from nested domain objects.
factory
Properties
-
childrenByParent
→ Map<
TKey, List< TKey> > -
Child keys keyed by parent node ID.
final
-
dataByKey
→ Map<
TKey, TItem> -
Payloads keyed by node ID.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
roots
→ List<
TKey> -
Root node keys in render order.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
buildChildren(
TKey parentKey) → List< TreeNode< TKey, TItem> > -
Converts the children of
parentKeyinto TreeNode objects. -
buildRoots(
) → List< TreeNode< TKey, TItem> > - Converts the snapshot roots into TreeNode objects for syncing.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
TKey key) → TItem? -
Gets the payload for
key, or null if missing.