exitFullscreen function

Future<void> exitFullscreen(
  1. BuildContext context
)

Makes the VideoControls present in the current BuildContext exit fullscreen.

Implementation

Future<void> exitFullscreen(BuildContext context) {
  return lock.synchronized(() async {
    if (isFullscreen(context)) {
      bool playerWasPlaying = player(context).state.playing;

      if (context.mounted) {
        await Navigator.of(context).maybePop();
        // It is known that this [context] will have a [FullscreenInheritedWidget] above it.
        if (context.mounted) {
          FullscreenInheritedWidget.of(context)
              .parent
              .refreshView(playerWasPlaying: playerWasPlaying);
        }
      }
      // [exitNativeFullscreen] is moved to [WillPopScope] in [FullscreenInheritedWidget].
      // This is because [exitNativeFullscreen] needs to be called when the user presses the back button.
    }
  });
}