visitChildElements static method

void visitChildElements(
  1. BuildContext context,
  2. ElementVisitor visitor

Walks the non-LookupBoundary child Elements of the provided context.

This method behaves exactly like BuildContext.visitChildElements, except it only visits children that are not a LookupBoundary.

This is useful for applying changes to children after they are built without waiting for the next frame, especially if the children are known, and especially if there is exactly one child (as is always the case for StatefulWidgets or StatelessWidgets).

Calling this method is very cheap for build contexts that correspond to StatefulWidgets or StatelessWidgets (O(1), since there's only one child).

Calling this method is potentially expensive for build contexts that correspond to RenderObjectWidgets (O(N) in the number of children).

Calling this method recursively is extremely expensive (O(N) in the number of descendants), and should be avoided if possible. Generally it is significantly cheaper to use an InheritedWidget and have the descendants pull data down, than it is to use visitChildElements recursively to push data down to them.


static void visitChildElements(BuildContext context, ElementVisitor visitor) {
  context.visitChildElements((Element child) {
    if (child.widget.runtimeType != LookupBoundary) {