adoptChild method Null safety

  1. @protected
  2. @mustCallSuper
void adoptChild(
  1. covariant AbstractNode child

Mark the given node as being a child of this node.

Subclasses should call this function when they acquire a new child.


void adoptChild(covariant AbstractNode child) {
  assert(child != null);
  assert(child._parent == null);
  assert(() {
    AbstractNode node = this;
    while (node.parent != null)
      node = node.parent!;
    assert(node != child); // indicates we are about to create a cycle
    return true;
  child._parent = this;
  if (attached)