didRebuild method

void didRebuild(
  1. Element element
)

Notifies the owner that element finished rebuilding.

Implementation

void didRebuild(Element element) {
  _dirty.remove(element);
  // Track that a rebuild occurred even outside beginFrame's buildScope
  // (e.g., during dispatch).  This ensures that paint caches (like the
  // scroll viewport's) are invalidated when a child widget was rebuilt
  // during message dispatch before the render pass begins.
  _hadBuildThisFrame = true;

  // Mark render-object ancestors as paint-dirty so viewport/list caches can
  // invalidate only along the changed subtree path instead of relying on a
  // frame-global "some build happened" signal.
  Element? current = element;
  while (current != null) {
    if (current is RenderObjectElement) {
      current.renderObject.markDescendantNeedsPaint();
    }
    current = current.parent;
  }

  // Ensure a paint pass is scheduled even when this rebuild happened during
  // message dispatch (outside the normal build phase).
  _needsPaint = true;
}