diff --git a/just_audio_background/lib/just_audio_background.dart b/just_audio_background/lib/just_audio_background.dart index be05c8e5b..f016dc899 100644 --- a/just_audio_background/lib/just_audio_background.dart +++ b/just_audio_background/lib/just_audio_background.dart @@ -140,16 +140,18 @@ class _JustAudioBackgroundPlugin extends JustAudioPlatform { @override Future disposePlayer( DisposePlayerRequest request) async { - await _player?.release(); + final player = _player; _player = null; + await player?.release(); return DisposePlayerResponse(); } @override Future disposeAllPlayers( DisposeAllPlayersRequest request) async { - await _player?.release(); + final player = _player; _player = null; + await player?.release(); return DisposeAllPlayersResponse(); } }