describeSemanticsClip method

  1. @override
Rect describeSemanticsClip (covariant RenderSliver child)
override

Returns a rect in this object's coordinate system that describes which SemanticsNodes produced by the child should be included in the semantics tree. SemanticsNodes from the child that are positioned outside of this rect will be dropped. Child SemanticsNodes that are positioned inside this rect, but outside of describeApproximatePaintClip will be included in the tree marked as hidden. Child SemanticsNodes that are inside of both rect will be included in the tree as regular nodes.

This method only returns a non-null value if the semantics clip rect is different from the rect returned by describeApproximatePaintClip. If the semantics clip rect and the paint clip rect are the same, this method returns null.

A viewport would typically implement this method to include semantic nodes in the semantics tree that are currently hidden just before the leading or just after the trailing edge. These nodes have to be included in the semantics tree to implement implicit accessibility scrolling on iOS where the viewport scrolls implicitly when moving the accessibility focus from a the last visible node in the viewport to the first hidden one.

Implementation

@override
Rect describeSemanticsClip(RenderSliver child) {
  assert (axis != null);
  switch (axis) {
    case Axis.vertical:
      return Rect.fromLTRB(
        semanticBounds.left,
        semanticBounds.top - cacheExtent,
        semanticBounds.right,
        semanticBounds.bottom + cacheExtent,
      );
    case Axis.horizontal:
      return Rect.fromLTRB(
        semanticBounds.left - cacheExtent,
        semanticBounds.top,
        semanticBounds.right + cacheExtent,
        semanticBounds.bottom,
      );
  }
  return null;
}