BuildOwner class Null safety

Manager class for the widgets framework.

This class tracks which widgets need rebuilding, and handles other tasks that apply to widget trees as a whole, such as managing the inactive element list for the tree and triggering the "reassemble" command when necessary during hot reload when debugging.

The main build owner is typically owned by the WidgetsBinding, and is driven from the operating system along with the rest of the build/layout/paint pipeline.

Additional build owners can be built to manage off-screen widget trees.

To assign a build owner to a tree, use the RootRenderObjectElement.assignOwner method on the root element of the widget tree.

This example shows how to build an off-screen widget tree used to measure the layout size of the rendered tree. For some use cases, the simpler Offstage widget may be a better alternative to this approach.
To create a local project with this code sample, run:
flutter create --sample=widgets.BuildOwner.1 mysample

Constructors

BuildOwner({VoidCallback? onBuildScheduled, FocusManager? focusManager})
Creates an object that manages widgets.

Properties

debugBuilding bool
Whether this widget tree is in the build phase.
read-only
focusManager FocusManager
The object in charge of the focus tree.
read / write
globalKeyCount int
The number of GlobalKey instances that are currently associated with Elements that have been built by this build owner.
read-only
hashCode int
The hash code for this object.
read-onlyinherited
onBuildScheduled VoidCallback?
Called on each build pass when the first buildable element is marked dirty.
read / write
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

buildScope(Element context, [VoidCallback? callback]) → void
Establishes a scope for updating the widget tree, and calls the given callback, if any. Then, builds all the elements that were marked as dirty using scheduleBuildFor, in depth order.
finalizeTree() → void
Complete the element build pass by unmounting any elements that are no longer active.
lockState(VoidCallback callback) → void
Establishes a scope in which calls to State.setState are forbidden, and calls the given callback.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
reassemble(Element root, DebugReassembleConfig? reassembleConfig) → void
Cause the entire subtree rooted at the given Element to be entirely rebuilt. This is used by development tools when the application code has changed and is being hot-reloaded, to cause the widget tree to pick up any changed implementations.
scheduleBuildFor(Element element) → void
Adds an element to the dirty elements list so that it will be rebuilt when WidgetsBinding.drawFrame calls buildScope.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited