LocalNode getOrCreateNode(String path, [ bool addToTree = true, bool init = true ])

Gets a node at the given path if it exists. If it does not exist, create a new node and return it.

When addToTree is false, the node will not be inserted into the node provider. When init is false, onCreated() is not called.

Source

LocalNode getOrCreateNode(String path, [bool addToTree = true, bool init = true]) {
  LocalNode node = _getNode(path, allowStubs: true);

  if (node != null) {
    if (addToTree) {
      Path po = new Path(path);
      if (!po.isRoot) {
        LocalNode parent = getNode(po.parentPath);

        if (parent != null && !parent.children.containsKey(po.name)) {
          parent.addChild(po.name, node);
          parent.listChangeController.add(po.name);
          node.listChangeController.add(r"$is");
        }
      }

      if (node is SimpleNode) {
        node._stub = false;
      }
    }

    return node;
  }

  if (addToTree) {
    return createNode(path, init);
  } else {
    node = new SimpleNode(path, this)
      .._stub = true;
    nodes[path] = node;
    return node;
  }
}