cancelOnClose method

void cancelOnClose(
  1. StreamSubscription subscription, [
  2. void onClose()?
])

Helper method to reduce boilerplate when composing BLoC's together.

Implementation

void cancelOnClose(
  StreamSubscription subscription, [
  void Function()? onClose,
]) {
  _closers.add(() {
    subscription.cancel();
    if (onClose != null) onClose();
  });
}