deactivateChild method Null safety
- Element child
protected">@protected
Move the given element to the list of inactive elements and detach its render object from the render tree.
This method stops the given element from being a child of this element by detaching its render object from the render tree and moving the element to the list of inactive elements.
This method (indirectly) calls deactivate on the child.
The caller is responsible for removing the child from its child model. Typically deactivateChild is called by the element itself while it is updating its child model; however, during GlobalKey reparenting, the new parent proactively calls the old parent's deactivateChild, first using forgetChild to cause the old parent to update its child model.
Implementation
@protected
void deactivateChild(Element child) {
assert(child != null);
assert(child._parent == this);
child._parent = null;
child.detachRenderObject();
owner!._inactiveElements.add(child); // this eventually calls child.deactivate()
assert(() {
if (debugPrintGlobalKeyedWidgetLifecycle) {
if (child.widget.key is GlobalKey) {
debugPrint('Deactivated $child (keyed child of $this)');
}
}
return true;
}());
}