当音频流停止时,我想弹出一个音乐播放器页面。但我收到了类似的错误
Unhandled Exception: Looking up a deactivated widget's ancestor is unsafe
这是我在返回脚手架之前放在 build 方法中的代码。
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");
}
}
});