cancelOnClose method
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();
});
}