addNode method

  1. @override
SimpleNode? addNode(
  1. String path,
  2. Map m
)
override

Adds a node at the given path that is initialized with the given data in m.

Implementation

@override
SimpleNode? addNode(String path, Map m) {
  if (path == '/' || !path.startsWith('/')) return null;

  var p = Path(path);
  var pnode = getNode(p.parentPath) as SimpleNode?;

  SimpleNode? node;

  if (pnode != null) {
    node = pnode.onLoadChild(p.name, m, this);
  }

  if (node == null) {
    String profile = m[r'$is'];
    if (profileMap.containsKey(profile)) {
      node = profileMap[profile]!(path) as SimpleNode?;
    } else {
      node = CallbackNode(path);
    }
  }

  nodes[path] = node as LocalNode;
  node?.load(m);

  node?.onCreated();

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

  return node;
}