dispose method Null safety

Future<void> dispose()

Release all resources associated with this player. You must invoke this after you are done with the player.

Implementation

Future<void> dispose() async {
  if (_disposed) return;
  _disposed = true;
  if (_nativePlatform != null) {
    await _disposePlatform(await _nativePlatform!);
    _nativePlatform = null;
  }
  if (_idlePlatform != null) {
    await _disposePlatform(_idlePlatform!);
    _idlePlatform = null;
  }
  _audioSource = null;
  _audioSources.values.forEach((s) => s._dispose());
  _audioSources.clear();
  _proxy?.stop();
  await _durationSubject.close();
  await _loopModeSubject.close();
  await _shuffleModeEnabledSubject.close();
  await _playingSubject.close();
  await _volumeSubject.close();
  await _speedSubject.close();
  await _pitchSubject.close();
  await _sequenceSubject.close();
  await _shuffleIndicesSubject.close();
}