mountWidget method

void mountWidget(
  1. Widget widget
)

Mounts or updates widget without laying it out or painting it.

This partial-phase operation is for framework tests that inspect build work or deliberately defer a render failure. Application tests use pumpWidget. Call owner.flushBuild() for later build-only updates, render for layout/paint, or pump to complete a frame.

Implementation

void mountWidget(Widget widget) {
  _assertNotDisposed('mountWidget');
  _currentUserWidget = widget;
  _openFrame();
  if (_root == null) {
    _root = _owner.mountRoot(_wrap());
  } else {
    // Stable wrappers + a stable OverlayEntry whose builder reads
    // _currentUserWidget on each rebuild. markNeedsBuild reaches
    // exactly the entry's subtree without disturbing the binding
    // / focus / overlay state above.
    _userEntry.markNeedsBuild();
    _owner.flushBuild();
  }
}