removeChild method

void removeChild(
  1. DomRenderObject child
)

Implementation

void removeChild(DomRenderObject child) {
  if (child case DomRenderFragment(isAttached: true)) {
    child.removeChildren(this);
  } else {
    if (kVerboseMode) {
      print('Remove child ${child.node} of $node');
    }

    assert(
      node == child.node.parentNode,
      'Child node must be a child of this element.',
    );

    node.removeChild(child.node);
  }

  // Unlink the removed child from its siblings.
  final oldPreviousSibling = child.previousSibling;
  final oldNextSibling = child.nextSibling;
  oldPreviousSibling?.nextSibling = oldNextSibling;
  oldNextSibling?.previousSibling = oldPreviousSibling;
  child.previousSibling = null;
  child.nextSibling = null;
  child.parent = null;
}