buildScope property

BuildScope get buildScope

A BuildScope whose dirty Elements can only be rebuilt by BuildOwner.buildScope calls whose context argument is an Element within this BuildScope.

The getter typically is only safe to access when this Element is mounted.

The default implementation returns the parent Element's buildScope, as in most cases an Element is ready to rebuild as soon as its ancestors are no longer dirty. One notable exception is LayoutBuilder's descendants, which must not rebuild until the incoming constraints become available. LayoutBuilder's Element overrides buildScope to make none of its descendants can rebuild until the incoming constraints are known.

If you choose to override this getter to establish your own BuildScope, to flush the dirty Elements in the BuildScope you need to manually call BuildOwner.buildScope with the root Element of your BuildScope when appropriate, as the Flutter framework does not try to register or manage custom BuildScopes.

Always return the same BuildScope instance if you override this getter. Changing the value returned by this getter at runtime is not supported.

The updateChild method ignores buildScope: if the parent Element calls updateChild on a child with a different BuildScope, the child may still rebuild.

See also:

Implementation

BuildScope get buildScope => _parentBuildScope!;