salmanjones / volume_watcher

watcher the volume change on android and ios platform
Apache License 2.0
12 stars 25 forks source link

onVolumeChangeListener is not receiving volume changes after VolumeWatcher has been disposed once. #13

Open vcrash opened 3 years ago

vcrash commented 3 years ago

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? }