detach method

  1. @override
void detach()
override

Mark this layer as detached from its owner.

Typically called only from the parent's detach, and by the owner to mark the root of a tree as detached.

Subclasses with children should override this method to detach all their children after calling the inherited method, as in super.detach().

Implementation

@override
void detach() {
  assert(!_debugMutationsLocked);
  super.detach();
  Layer? child = firstChild;
  while (child != null) {
    child.detach();
    child = child.nextSibling;
  }
  // Detach indicates that we may never be composited again. Clients
  // interested in observing composition need to get an update here because
  // they might otherwise never get another one even though the layer is no
  // longer visible.
  //
  // Children fired them already in child.detach().
  _fireCompositionCallbacks(includeChildren: false);
}