ensureSemantics method
Opens a SemanticsHandle and calls listener
whenever the semantics tree
updates.
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;
if (_outstandingSemanticsHandles == 1) {
assert(_semanticsOwner == null);
_semanticsOwner = SemanticsOwner();
if (onSemanticsOwnerCreated != null)
onSemanticsOwnerCreated();
}
return SemanticsHandle._(this, listener);
}