detach method

  1. @override
void detach()
override

Mark this render object as detached from its PipelineOwner.

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() {
  _controller.unregisterRenderHost(_hostCallback);
  // A pending FLIP baseline AND any registered ghosts may carry stale
  // state across the detach/re-attach gap (e.g. ghost entries against
  // freed nids). `_composer.reset()` drops both maps. Practical impact
  // is muted because the next `_consumeSlideBaselineIfAny` would also
  // run `pruneSettled`, but this defense-in-depth catches the race
  // where a structural mutation happens while detached.
  _composer.reset();
  // Out-of-layout scratch can hold extents against the now-stale
  // controller state; drop it so re-attach materializes fresh.
  _findFirstScratchCumulative = null;
  _findFirstScratchGen = -1;
  _findFirstScratchCount = 0;
  super.detach();
  for (final child in _children.values) {
    child.detach();
  }
}