visitChildrenForSemantics method

  1. @override
void visitChildrenForSemantics(
  1. RenderObjectVisitor visitor
)
override

Filters out children whose nodes have been removed from the controller (or are mid-exit) so screen readers don't announce/focus them while the render boxes wait for their post-frame eviction.

Walks in visual order (sticky headers first, then in-flow visible nodes top-to-bottom) so screen readers announce rows in the same order the user sees them rather than raw insertion order.

Implementation

@override
void visitChildrenForSemantics(RenderObjectVisitor visitor) {
  // Sticky headers paint on top, shallowest first (visual top).
  for (final sticky in _sticky.headers) {
    final child = getChildForNode(sticky.nodeId);
    if (child == null) continue;
    if (controller.getNodeData(sticky.nodeId) == null) continue;
    if (controller.isExiting(sticky.nodeId)) continue;
    visitor(child);
  }
  // Then in-flow visible nodes, skipping any already emitted as sticky.
  for (final nodeId in controller.visibleNodes) {
    final nid = _controller.nidOf(nodeId);
    if (_sticky.isSticky(nid)) continue;
    final child = getChildForNode(nodeId);
    if (child == null) continue;
    if (controller.getNodeData(nodeId) == null) continue;
    if (controller.isExiting(nodeId)) continue;
    visitor(child);
  }
}