ensureSemantics method
- {VoidCallback? listener}
Opens a SemanticsHandle and calls listener
whenever the semantics tree
generated from the render tree owned by this PipelineOwner updates.
Calling this method only ensures that this particular PipelineOwner will generate a semantics tree. Consider calling SemanticsBinding.ensureSemantics instead to turn on semantics globally for the entire app.
The PipelineOwner updates the semantics tree only when there are clients that wish to use the semantics tree. These clients express their interest by holding SemanticsHandle objects that notify them whenever the semantics tree updates.
Clients can close their SemanticsHandle by calling SemanticsHandle.dispose. Once all the outstanding SemanticsHandle objects for a given PipelineOwner are closed, the PipelineOwner stops maintaining the semantics tree.
Implementation
SemanticsHandle ensureSemantics({ VoidCallback? listener }) {
_outstandingSemanticsHandles += 1;
_updateSemanticsOwner();
return _LocalSemanticsHandle._(this, listener);
}