adoptChild method Null safety
- covariant AbstractNode child
mustCallSuper">@mustCallSuperprotected">@protected
Mark the given node as being a child of this node.
Subclasses should call this function when they acquire a new child.
Implementation
@protected
@mustCallSuper
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) {
child.attach(_owner!);
}
redepthChild(child);
}