describeSemanticsConfiguration method

  1. @override
void describeSemanticsConfiguration (SemanticsConfiguration config)
override

Report the semantics of this node, for example for accessibility purposes.

This method should be overridden by subclasses that have interesting semantic information.

The given SemanticsConfiguration object is mutable and should be annotated in a manner that describes the current state. No reference should be kept to that object; mutating it outside of the context of the describeSemanticsConfiguration call (for example as a result of asynchronous computation) will at best have no useful effect and at worse will cause crashes as the data will be in an inconsistent state.

{@tool sample}

The following snippet will describe the node as a button that responds to tap actions.

abstract class SemanticButtonRenderObject extends RenderObject {
  @override
  void describeSemanticsConfiguration(SemanticsConfiguration config) {
    super.describeSemanticsConfiguration(config);
    config
      ..onTap = _handleTap
      ..label = 'I am a button'
      ..isButton = true;
  }

  void _handleTap() {
    // Do something.
  }
}

{@end-tool}

Implementation

@override
void describeSemanticsConfiguration(SemanticsConfiguration config) {
  super.describeSemanticsConfiguration(config);

  if (_excludeFromSemanticsScrolling)
    config.addTagForChildren(RenderViewport.excludeFromScrolling);
}