removeChild method Null safety

  1. @override
void removeChild(
  1. DisplayObject child

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.


void removeChild(DisplayObject child) {
  if (child.parent != this) {
    throw ArgumentError(
        'The supplied DisplayObject must be a child of the caller.');
  } else {
    final index = _children.indexOf(child);