0

I cant dismiss ongoing notification. It cant be dismissed programmatically - it always stays visible. User can swipe it away.

Implementation is same as here: implementation example

I want it to dismiss when the user closes this screen.

This does not work:

final session = await AudioSession.instance;
await session.setActive(false);

2 Answers2

1

To dismiss audio_service's notification, you need to use methods of the audio_service package, not methods of the audio_session package. From the documentation of BaseAudioHandler.stop():

Stop playback and release resources.

The default implementation (which may be overridden) updates playbackState by setting the processing state to AudioProcessingState.idle which disables the system notification.

So to dismiss the notification programmatically, you can call this method.

Ryan Heise
  • 2,273
  • 5
  • 14
-1

Fixed by adding super.stop(); to overriden stop method. Thanks !