withLifecycle method

StreamSubscription<T> withLifecycle(
  1. RaiiLifecycleAware lifecycleAware, {
  2. String? debugLabel,
})

Attaches this StreamSubscription to a RaiiLifecycleAware object.

The subscription will be automatically cancelled when the lifecycle is disposed.

Returns the original StreamSubscription for chaining.

Implementation

StreamSubscription<T> withLifecycle(
  RaiiLifecycleAware lifecycleAware, {
  String? debugLabel,
}) {
  _StreamSubscriptionRaiiLifecycle.withLifecycle(
    lifecycleAware,
    sub: this,
    debugLabel: debugLabel,
  );

  return this;
}