dispose method

  1. @mustCallSuper
void dispose ()
@mustCallSuper

Closes the semantics handle and stops calling listener when the semantics updates.

When all the outstanding SemanticsHandle objects for a given PipelineOwner are closed, the PipelineOwner will stop updating the semantics tree.

Implementation

@mustCallSuper
void dispose() {
  assert(() {
    if (_owner == null) {
      throw FlutterError(
        'SemanticsHandle has already been disposed.\n'
        'Each SemanticsHandle should be disposed exactly once.'
      );
    }
    return true;
  }());
  if (_owner != null) {
    if (listener != null)
      _owner.semanticsOwner.removeListener(listener);
    _owner._didDisposeSemanticsHandle();
    _owner = null;
  }
}