dispose method

Future<void> dispose([
  1. AsyncCallback? restoreHotkeysCallback
])

dispose de video_player controller

Implementation

Future<void> dispose([AsyncCallback? restoreHotkeysCallback]) async {
  _timer?.cancel();
  _timerForVolume?.cancel();
  _timerForGettingVolume?.cancel();
  timerForTrackingMouse?.cancel();
  _timerForSeek?.cancel();
  videoFitChangedTimer?.cancel();

  _position.close();
  _playerEventSubs?.cancel();
  _sliderPosition.close();
  _duration.close();
  _buffered.close();
  _closedCaptionEnabled.close();
  _mute.close();
  _fullscreen.close();
  _showControls.close();
  if (windows && !UniversalPlatform.isWeb) {
    HotKeyManager.instance
        .unregisterAll()
        .then((value) => restoreHotkeysCallback?.call());
  }
  playerStatus.status.close();
  dataStatus.status.close();

  _videoPlayerController?.removeListener(_listener);
  await _videoPlayerController?.dispose();
  _videoPlayerController = null;
}