feat: Expose stream controller onCancel and hasListener
- Dominant language
- Dart
- Stars
- 12.5k
- Forks
- 3.4k
- PR merge metrics
- No merged PRs in 30d
Description
**Description**
It would be great to know when all active listeners to a bloc are removed or whether there are any listeners to a bloc.
**Desired Solution**
Expose the stream controller's `onCancel` callback and `hasListener`.
**Additional Context**
This would be useful for removing or changing state when a screen goes out of view. Say you need to have a bloc that wraps the whole app but the state stored is large and is only needed on 2 pages. Right now I would have to put add an event in the dispose method of the page. It would be good if there was a `onCancel` override similar to `onChange`. This `onCancel` could be called when the stream controllers `onCancel` is called. Having `hasListener` available would be a nice to have as well.
Contributor guide
Assessment
This issue has not been assessed yet.