collapseItem<K> static method

List<TreeNode<K>> collapseItem<K>(
  1. List<TreeNode<K>> nodes,
  2. K target
)

Implementation

static List<TreeNode<K>> collapseItem<K>(List<TreeNode<K>> nodes, K target) {
  return replaceNodes(nodes, (node) {
    if (node is TreeItem<K> && node.data == target && node.expanded) {
      return node.updateState(expanded: false);
    }
    return null;
  });
}