semanticsBuilder property

  1. @override
SemanticsBuilderCallback semanticsBuilder
override

Returns a function that builds semantic information for the picture drawn by this painter.

If the returned function is null, this painter will not contribute new SemanticsNodes to the semantics tree and the CustomPaint corresponding to this painter will not create a semantics boundary. However, if the child of a CustomPaint is not null, the child may contribute SemanticsNodes to the tree.

See also:

Implementation

@override
SemanticsBuilderCallback get semanticsBuilder {
  return (Size size) {
    // Annotate a the entire P5 widget with the label "P5 Sketch".
    // When text to speech feature is enabled on the device, a user will be
    // able to locate the sun on this picture by touch.
    var rect = Offset.zero & size;
    rect = const Alignment(0.0, 0.0).inscribe(size, rect);
    return [
      new CustomPainterSemantics(
        rect: rect,
        properties: new SemanticsProperties(
          label: 'P5 Sketch',
          textDirection: TextDirection.ltr,
        ),
      ),
    ];
  };
}