When removeListener is called after widget dispose event subscription is cancelling.
Then if you navigate to page containing VolumeWatcher again it seems subscription will be not renew during addListener call.
_subscription ??= eventChannel does not work since _subscription is not null and has been cancelled.
So onVolumeChangeListener of VolumeWatcher widget will be not called on volume change.
Can you check this case?
static void removeListener(int? id) {
if (id != null) {
_events.remove(id);
}
_subscription?.cancel();
// _subscription = null; // <- did you forgot this?
}
When removeListener is called after widget dispose event subscription is cancelling. Then if you navigate to page containing VolumeWatcher again it seems subscription will be not renew during addListener call. _subscription ??= eventChannel does not work since _subscription is not null and has been cancelled. So onVolumeChangeListener of VolumeWatcher widget will be not called on volume change. Can you check this case?
static void removeListener(int? id) { if (id != null) { _events.remove(id); } _subscription?.cancel(); // _subscription = null; // <- did you forgot this? }