assembleSemanticsNode method
void
assembleSemanticsNode(
- SemanticsNode node,
- SemanticsConfiguration config,
- Iterable<
SemanticsNode> children
override
Assemble the SemanticsNode for this RenderObject.
If describeSemanticsConfiguration sets
SemanticsConfiguration.isSemanticBoundary to true, this method is called
with the node created for this RenderObject, the config to be
applied to that node and the children SemanticsNodes that descendants
of this RenderObject have generated.
By default, the method will annotate node with config and add the
children to it.
Subclasses can override this method to add additional SemanticsNodes to the tree. If new SemanticsNodes are instantiated in this method they must be disposed in clearSemantics.
Implementation
@override
void assembleSemanticsNode(SemanticsNode node, SemanticsConfiguration config, Iterable<SemanticsNode> children) {
final CSSOverflowType overflowX = renderStyle.effectiveOverflowX;
final CSSOverflowType overflowY = renderStyle.effectiveOverflowY;
final bool xScrollable =
(overflowX == CSSOverflowType.scroll || overflowX == CSSOverflowType.auto) && scrollOffsetX != null;
final bool yScrollable =
(overflowY == CSSOverflowType.scroll || overflowY == CSSOverflowType.auto) && scrollOffsetY != null;
if (!xScrollable && !yScrollable) {
super.assembleSemanticsNode(node, config, children);
return;
}
final List<SemanticsNode> childList = children is List<SemanticsNode> ? children : children.toList(growable: false);
int? firstVisibleIndex;
for (final SemanticsNode child in childList) {
if (!child.flagsCollection.isHidden) {
firstVisibleIndex ??= child.indexInParent;
}
}
config.scrollIndex = firstVisibleIndex;
config.scrollChildCount = childList.length;
node.updateWith(config: config, childrenInInversePaintOrder: childList);
}