enterFullscreen function
Makes the Video present in the current BuildContext enter fullscreen.
Implementation
Future<void> enterFullscreen(BuildContext context) {
return lock.synchronized(() async {
if (!isFullscreen(context)) {
if (context.mounted) {
final stateValue = state(context);
final contextNotifierValue = contextNotifier(context);
final videoViewParametersNotifierValue =
videoViewParametersNotifier(context);
final controllerValue = controller(context);
Navigator.of(context, rootNavigator: true).push(
PageRouteBuilder(
pageBuilder: (_, __, ___) => Material(
child: VideoControlsThemeDataInjector(
// NOTE: Make various *VideoControlsThemeData from the parent context available in the fullscreen context.
context: context,
child: VideoStateInheritedWidget(
state: stateValue,
contextNotifier: contextNotifierValue,
videoViewParametersNotifier: videoViewParametersNotifierValue,
disposeNotifiers: false,
child: FullscreenInheritedWidget(
parent: stateValue,
// Another [VideoStateInheritedWidget] inside [FullscreenInheritedWidget] is important to notify about the fullscreen [BuildContext].
child: VideoStateInheritedWidget(
state: stateValue,
contextNotifier: contextNotifierValue,
videoViewParametersNotifier:
videoViewParametersNotifierValue,
disposeNotifiers: false,
child: Video(
controller: controllerValue,
// Do not restrict the video's width & height in fullscreen mode:
width: null,
height: null,
fit: videoViewParametersNotifierValue.value.fit,
fill: videoViewParametersNotifierValue.value.fill,
alignment:
videoViewParametersNotifierValue.value.alignment,
aspectRatio:
videoViewParametersNotifierValue.value.aspectRatio,
filterQuality: videoViewParametersNotifierValue
.value.filterQuality,
controls:
videoViewParametersNotifierValue.value.controls,
// Do not acquire or modify existing wakelock in fullscreen mode:
wakelock: false,
pauseUponEnteringBackgroundMode:
stateValue.widget.pauseUponEnteringBackgroundMode,
resumeUponEnteringForegroundMode:
stateValue.widget.resumeUponEnteringForegroundMode,
subtitleViewConfiguration:
videoViewParametersNotifierValue
.value.subtitleViewConfiguration,
onEnterFullscreen: stateValue.widget.onEnterFullscreen,
onExitFullscreen: stateValue.widget.onExitFullscreen,
),
),
),
),
),
),
transitionDuration: Duration.zero,
reverseTransitionDuration: Duration.zero,
),
);
await onEnterFullscreen(context)?.call();
}
}
});
}