refreshNode method

  1. @override
void refreshNode(
  1. TreeNode node, {
  2. bool keepExpandedNodes = false,
})

Refreshes node's subtree.

Useful when node.children has changed. But be careful, this method could slow down your view as it collapses and re-expands the nodes.

If node is not expanded, nothing happens.

Set keepExpandedNodes to true if you want to preserve the expansion state of the subtree of node.

Implementation

@override
void refreshNode(TreeNode node, {bool keepExpandedNodes = false}) {
  if (node.hasChildren) {
    node.descendants
        .where((descendant) => isVisible(descendant.id))
        .forEach((child) => _nodesThatShouldRefresh[child.id] = true);
  }

  super.refreshNode(node, keepExpandedNodes: keepExpandedNodes);
  notifyListeners();
}