Add sample code for describeSemanticsConfiguration (#12830)
This commit is contained in:
parent
83df7bdd0f
commit
e023e89b8e
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user