TreeSyncController<TKey, TData> class

A controller that syncs a TreeController to a desired state using animated diffs.

This controller does not own the TreeController; it drives it. Dispose this controller before disposing the underlying TreeController.

Composes with direct controller mutations. Every diff reads the controller's live state (TreeController.liveRootKeys / TreeController.getLiveChildren) as its "current" baseline, so structural mutations that bypass this controller (imperative insert/remove/moveNode calls through an escape-hatch reference, or TreeReorderController committing a drag-drop) are simply the new baseline for the next sync. No resync hook is needed.

Constructors

TreeSyncController({required TreeController<TKey, TData> treeController, int expansionMemory = defaultExpansionMemory})
Creates a sync controller.

Properties

expansionMemory → int
Maximum number of entries in _rememberedExpansion. When exceeded, the oldest are evicted: Dart maps iterate in first-insertion order, and re-recording an existing key does not move it, so eviction is FIFO by when a key was FIRST remembered. 0 disables the memory entirely: nothing is remembered or restored across remove/re-add.
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
treeController → TreeController<TKey, TData>
The underlying TreeController being driven.
no setter

Methods

clearExpansionMemory() → void
Clears all remembered expansion state.
dispose() → void
Drops all expansion memory. Call before disposing the underlying TreeController, which this controller drives but does not own.
initializeTracking() → void
A no-op, and deliberately still called.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
snapshotChildPresence() → Map<TKey, bool>
Every live node's key, mapped to whether it currently has live children.
snapshotCurrentChildren() → Map<TKey, List<TKey>>
Returns a deep-copied snapshot of the current live child order, derived from the controller.
snapshotRememberedKeys() → Set<TKey>
Returns the set of keys currently held in expansion memory, plus parents whose child list was emptied by a sync while they survived collapsed.
syncChildren(TKey parentKey, List<TreeNode<TKey, TData>> desired, {bool animate = true}) → void
Syncs the children of parentKey to match desired.
syncMultipleChildren(Map<TKey, List<TreeNode<TKey, TData>>> desiredByParent, {bool animate = true}) → void
Syncs children for multiple parents in a single batch.
syncRoots(List<TreeNode<TKey, TData>> desired, {List<TreeNode<TKey, TData>> childrenOf(TKey key)?, bool animate = true}) → void
Syncs the root nodes to match desired.
toString() → String
A string representation of this object.
inherited

Operators

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

Constants

defaultExpansionMemory → const int
The default expansionMemory capacity. Named so the layers that forward it (SyncedSliverTree.expansionMemory, the sectioned module's preserveExpansion bool) cannot drift from it silently.