I want to pop out a music player page when the audio stream is stopped. But I am getting error like
Unhandled Exception: Looking up a deactivated widget's ancestor is unsafe
This is my code which I have placed inside the build method before returning scaffold.
AudioService.playbackStateStream.listen((event) {
if (event?.processingState == AudioProcessingState.stopped) {
try {
final modal = ModalRoute.of(context);
if (modal.isCurrent) {
Navigator.of(context).pop();
}
} catch (e) {
print("exception error in player adv $e");
}
}
});