expandNode method

void expandNode(
  1. NodeViewModelState node
)

Expands the given node so its children become visible.

This will change the node NodeViewModelState.isCollapsed property to false. 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 expandNode(NodeViewModelState node) {
  if (!node.isCollapsed || !node.isRoot) {
    return;
  }

  final nodeIndex = _displayNodes.indexOf(node) + 1;
  final nodes = flatten(node.value);
  _displayNodes.insertAll(nodeIndex, nodes);
  node.expand();
  notifyListeners();
}