removeChild method

  1. @override
void removeChild (DisplayObject child)
override

Removes the specified child from the child list of this DisplayObjectContainer.

The parent property of the removed child is set to null, and the object is garbage collected if no other references to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are decreased by 1.

Implementation

@override
void removeChild(DisplayObject child) {
  if (child.parent != this) {
    throw ArgumentError(
        "The supplied DisplayObject must be a child of the caller.");
  } else {
    int index = _children.indexOf(child);
    _clearChildParent(child);
    _children.removeAt(index);
  }
}