describeSemantics method

  1. @override
void describeSemantics (Accumulator offset, List<int> semanticsOffsets, List semanticsElements)
override

Populates the semanticsOffsets and semanticsElements with the appropriate data to be able to construct a SemanticsNode.

If applicable, the beginning and end text offset are added to semanticsOffsets. PlaceholderSpans have a text length of 1, which corresponds to the object replacement character (0xFFFC) that is inserted to represent it.

Any GestureRecognizers are added to semanticsElements. Null is added to semanticsElements for PlaceholderSpans.

Implementation

@override
void describeSemantics(Accumulator offset, List<int> semanticsOffsets, List<dynamic> semanticsElements) {
  if (recognizer != null && (recognizer is TapGestureRecognizer || recognizer is LongPressGestureRecognizer)) {
    final int length = semanticsLabel?.length ?? text.length;
    semanticsOffsets.add(offset.value);
    semanticsOffsets.add(offset.value + length);
    semanticsElements.add(recognizer);
  }
  offset.increment(text != null ? text.length : 0);
}