description

# StreamSubscription<T> class abstract interface

A subscription on events from a Stream.

When you listen on a Stream using Stream.listen, a StreamSubscription object is returned.

The subscription provides events to the listener, and holds the callbacks used to handle the events. The subscription can also be used to unsubscribe from the events, or to temporarily pause the events from the stream.

Example:

    final stream = Stream.periodic(const Duration(seconds: 1), (i) => i * i)
        .take(10);

    final subscription = stream.listen(print); // A StreamSubscription<int>.

To pause the subscription, use pause.

    // Do some work.
    subscription.pause();
    print(subscription.isPaused); // true

To resume after the pause, use resume.

    // Do some work.
    subscription.resume();
    print(subscription.isPaused); // false

To cancel the subscription, use cancel.

    // Do some work.
    subscription.cancel();

## Properties

hashCode → int
  The hash code for this object.
  no setter inherited
isPaused → bool
  Whether the StreamSubscription is currently paused.
  no setter
runtimeType → Type
  A representation of the runtime type of the object.
  no setter inherited

## Methods

asFuture<E>([E? futureValue]) → Future<E>
  Returns a future that handles the onDone and onError callbacks.
cancel() → Future<void>
  Cancels this subscription.
noSuchMethod(Invocation invocation) → dynamic
  Invoked when a nonexistent method or property is accessed.
  inherited
onData(void handleData(T data)?) → void
  Replaces the data event handler of this subscription.
onDone(void handleDone()?) → void
  Replaces the done event handler of this subscription.
onError(Function? handleError) → void
  Replaces the error event handler of this subscription.
pause([Future<void>? resumeSignal]) → void
  Requests that the stream pauses events until further notice.
resume() → void
  Resumes after a pause.
toString() → String
  A string representation of this object.
  inherited

## Operators

operator ==(Object other) → bool
  The equality operator.
  inherited