debugVisitOnstageChildren method

  1. @override
void debugVisitOnstageChildren(
  1. ElementVisitor visitor
)
override

Calls the argument for each child considered onstage.

Classes like Offstage and Overlay override this method to hide their children.

Being onstage affects the element's discoverability during testing when you use Flutter's Finder objects. For example, when you instruct the test framework to tap on a widget, by default the finder will look for onstage elements and ignore the offstage ones.

The default implementation defers to visitChildren and therefore treats the element as onstage.

See also:

Implementation

@override
void debugVisitOnstageChildren(ElementVisitor visitor) {
  _childElements.values.cast<Element>().where((Element child) {
    final SliverMultiBoxAdaptorParentData parentData = child.renderObject!.parentData! as SliverMultiBoxAdaptorParentData;
    final double itemExtent = switch (renderObject.constraints.axis) {
      Axis.horizontal => child.renderObject!.paintBounds.width,
      Axis.vertical   => child.renderObject!.paintBounds.height,
    };

    return parentData.layoutOffset != null &&
        parentData.layoutOffset! < renderObject.constraints.scrollOffset + renderObject.constraints.remainingPaintExtent &&
        parentData.layoutOffset! + itemExtent > renderObject.constraints.scrollOffset;
  }).forEach(visitor);
}