collapseNode method

void collapseNode(
  1. NodeViewModelState node
)

Collapses the given node so its children won't be visible.

This will change the node NodeViewModelState.isCollapsed property to true. But its children won't change states, so when the node is expanded its children states are unchanged.

notifyListeners is called to notify all registered listeners.

See also:

Implementation

void collapseNode(NodeViewModelState node) {
  if (node.isCollapsed || !node.isRoot) {
    return;
  }

  final nodeIndex = _displayNodes.indexOf(node) + 1;
  final children = _visibleChildrenCount(node) - 1;
  _displayNodes.removeRange(nodeIndex, nodeIndex + children);
  node.collapse();
  notifyListeners();
}