Add sample code for describeSemanticsConfiguration (#12830)

This commit is contained in:
Michael Goderbauer 2017-11-01 15:49:28 -07:00 committed by GitHub
parent 83df7bdd0f
commit e023e89b8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2125,6 +2125,28 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
/// [describeSemanticsConfiguration] call (for example as a result of /// [describeSemanticsConfiguration] call (for example as a result of
/// asynchronous computation) will at best have no useful effect and at worse /// asynchronous computation) will at best have no useful effect and at worse
/// will cause crashes as the data will be in an inconsistent state. /// 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 @protected
void describeSemanticsConfiguration(SemanticsConfiguration config) { void describeSemanticsConfiguration(SemanticsConfiguration config) {
// Nothing to do by default. // Nothing to do by default.