cancel method

Future<void> cancel()

Cancels the current stream subscription.

Implementation

Future<void> cancel() async {
  await _subscription?.cancel();
  _subscription = null;
  if (_state.value != StreamState.closed) {
    _state.value = StreamState.idle;
  }
}