sliver_tree/tree_sync_controller library

A diffing/syncing layer on top of TreeController.

TreeSyncController tracks the current tree state, computes diffs against a desired state, and applies animated insert/remove operations. It also preserves expansion state across remove/re-add cycles.

Use syncRoots to sync the top-level nodes and syncChildren to sync the children of a specific parent.

Example:

final treeController = TreeController<String, String>(vsync: this);
final syncController = TreeSyncController(treeController: treeController);

// Sync roots with optional children provider
syncController.syncRoots(
  [TreeNode(key: 'a', data: 'A'), TreeNode(key: 'b', data: 'B')],
  childrenOf: (key) => [TreeNode(key: '${key}_1', data: 'Child 1')],
);

// Sync children of a specific parent
syncController.syncChildren('a', [
  TreeNode(key: 'a_1', data: 'Child 1'),
  TreeNode(key: 'a_2', data: 'Child 2'),
]);

Classes

TreeSyncController<TKey, TData>
A controller that syncs a TreeController to a desired state using animated diffs.