doOnCancel method Null safety

Stream<T> doOnCancel(
  1. FutureOr<void> onCancel(
      )
    )

    Invokes the given callback function when the stream subscription is cancelled. Often called doOnUnsubscribe or doOnDispose in other implementations.

    Example

    final subscription = TimerStream(1, Duration(minutes: 1))
      .doOnCancel(() => print('hi'))
      .listen(null);
    
    subscription.cancel(); // prints 'hi'
    

    Implementation

    Stream<T> doOnCancel(FutureOr<void> Function() onCancel) =>
        transform(DoStreamTransformer<T>(onCancel: onCancel));