updateRecursiveSelection<K> static method

List<TreeNode<K>> updateRecursiveSelection<K>(
  1. List<TreeNode<K>> nodes
)

Updates selection state to maintain parent-child consistency.

Parameters:

  • nodes (List<TreeNode<K>>, required): Tree nodes.

Returns: List<TreeNode<K>> — tree with updated selection.

Implementation

static List<TreeNode<K>> updateRecursiveSelection<K>(
    List<TreeNode<K>> nodes) {
  return replaceNodesWithParent(nodes, (parent, node) {
    if (node is TreeItemNode<K> &&
        !node.selected &&
        parent != null &&
        parent.selected) {
      return node.updateState(selected: true);
    }
    return null;
  });
}