Unverified Commit e023e89b authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Add sample code for describeSemanticsConfiguration (#12830)

parent 83df7bdd
......@@ -2125,6 +2125,28 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
/// [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.
///
/// ## Sample code
///
/// The following snippet will describe the node as a button that responds to
/// tap actions.
///
/// ```dart
/// abstract class SemanticButtonRenderObject extends RenderObject {
/// @override
/// void describeSemanticsConfiguration(SemanticsConfiguration config) {
/// super.describeSemanticsConfiguration(config);
/// config
/// ..addAction(SemanticsAction.tap, _handleTap)
/// ..label = 'I am a button'
/// ..isButton = true;
/// }
///
/// void _handleTap() {
/// // Do something.
/// }
/// }
/// ```
@protected
void describeSemanticsConfiguration(SemanticsConfiguration config) {
// Nothing to do by default.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment