setNode method

void setNode(
  1. String path,
  2. SimpleNode node, {
  3. bool registerChildren = false,
})

Sets the given node to the given path.

Implementation

void setNode(String path, SimpleNode node, {bool registerChildren = false}) {
  if (path == '/' || !path.startsWith('/')) return null;
  var p = Path(path);
  var pnode = getNode(p.parentPath) as SimpleNode?;

  nodes[path] = node;

  node.onCreated();

  if (pnode != null) {
    pnode.children[p.name] = node;
    pnode.onChildAdded(p.name, node);
    pnode.updateList(p.name);
  }

  if (registerChildren) {
    for (var c in node.children.values.cast<SimpleNode>()) {
      setNode(c.path, c);
    }
  }
}