syncRoots method
void
syncRoots(})
Syncs the root nodes to match desired.
Roots present in the tree but absent from desired are removed.
Roots in desired but not in the tree are inserted at the correct index.
The order of desired is respected.
If childrenOf is provided, it is called recursively for every node
in the desired tree — roots and their descendants — to sync children
at all depths. Return an empty list for leaf nodes. If a re-added node
was previously expanded (and preserveExpansion is true), it is
automatically expanded after its children are set.
Set animate to false to suppress animations (useful for initial setup).
Implementation
void syncRoots(
List<TreeNode<TKey, TData>> desired, {
List<TreeNode<TKey, TData>> Function(TKey key)? childrenOf,
bool animate = true,
}) {
_assertNoDuplicateKeys(desired, "syncRoots");
_controller.runBatch(() {
_syncRootsImpl(desired, childrenOf: childrenOf, animate: animate);
});
}