detach method

Future<void> detach()

Stops forwarding events from the source stream.

Normally called automatically when the stream looses the last subscription.

Implementation

Future<void> detach() async {
  detachCount += 1;

  if ((detachCount >= 0 || !_streamController!.hasListener) &&
      _sourceSubscription != null) {
    log("DETACH");
    await _sourceSubscription!.cancel();
    _sourceSubscription = null;

    if (_onCancel != null) {
      await _onCancel!();
    }
  }
}