clear method

void clear({
  1. bool? notify,
})

Cancels the StreamSubscription and ignores the Future if applicable.

Implementation

void clear({bool? notify}) {
  bool canceled = false;
  if (_future case final future?) {
    future.ignore();
    _future = null;
    canceled = true;
  }
  if (_subscription case final subscription?) {
    subscription.cancel();
    _subscription = null;
    canceled = true;
  }
  if (canceled) {
    notify ?? notifyOnCancel
        ? value = value.inState(ConnectionState.none)
        : connectionState = ConnectionState.none;
  }
}