visitChildElements abstract method

void visitChildElements(
  1. ElementVisitor visitor

Walks the children of this widget.

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.


void visitChildElements(ElementVisitor visitor);