removeAllChildren method Null safety

void removeAllChildren()

Removes all of this layer's children from its child list.

Implementation

void removeAllChildren() {
  assert(!_debugMutationsLocked);
  Layer? child = firstChild;
  while (child != null) {
    final Layer? next = child.nextSibling;
    child._previousSibling = null;
    child._nextSibling = null;
    assert(child.attached == attached);
    dropChild(child);
    assert(child._parentHandle != null);
    child._parentHandle.layer = null;
    child = next;
  }
  _firstChild = null;
  _lastChild = null;
}