From a4d847b57161b83d2d80d86ecedbae1653d7f746 Mon Sep 17 00:00:00 2001 From: Ortes Date: Fri, 19 Sep 2025 16:25:27 -0300 Subject: [PATCH 1/2] Add swipedown exists fullscreen feature --- lib/src/chewie_player.dart | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/src/chewie_player.dart b/lib/src/chewie_player.dart index 7ffa295b2..64a0baf73 100644 --- a/lib/src/chewie_player.dart +++ b/lib/src/chewie_player.dart @@ -104,10 +104,19 @@ class ChewieState extends State { ) { return Scaffold( resizeToAvoidBottomInset: false, - body: Container( - alignment: Alignment.center, - color: Colors.black, - child: controllerProvider, + body: GestureDetector( + onVerticalDragEnd: (DragEndDetails details) { + // A positive dy indicates a downward swipe. Use a threshold to avoid accidental triggers. + final double dy = details.primaryVelocity ?? 0; + if (dy > 300) { + widget.controller.exitFullScreen(); + } + }, + child: Container( + alignment: Alignment.center, + color: Colors.black, + child: controllerProvider, + ), ), ); } From 09747351dd00268d1d282972a0f4a02691213c5a Mon Sep 17 00:00:00 2001 From: Ortes Date: Mon, 22 Sep 2025 07:04:18 -0300 Subject: [PATCH 2/2] Make swipe down to exit fullscreen an option --- lib/src/chewie_player.dart | 48 +++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/lib/src/chewie_player.dart b/lib/src/chewie_player.dart index 64a0baf73..084db79c4 100644 --- a/lib/src/chewie_player.dart +++ b/lib/src/chewie_player.dart @@ -104,20 +104,26 @@ class ChewieState extends State { ) { return Scaffold( resizeToAvoidBottomInset: false, - body: GestureDetector( - onVerticalDragEnd: (DragEndDetails details) { - // A positive dy indicates a downward swipe. Use a threshold to avoid accidental triggers. - final double dy = details.primaryVelocity ?? 0; - if (dy > 300) { - widget.controller.exitFullScreen(); - } - }, - child: Container( - alignment: Alignment.center, - color: Colors.black, - child: controllerProvider, - ), - ), + body: widget.controller.swipeToExitFullscreen + ? GestureDetector( + onVerticalDragEnd: (DragEndDetails details) { + // A positive dy indicates a downward swipe. Use a threshold to avoid accidental triggers. + final double dy = details.primaryVelocity ?? 0; + if (dy > widget.controller.swipeThreshold) { + widget.controller.exitFullScreen(); + } + }, + child: Container( + alignment: Alignment.center, + color: Colors.black, + child: controllerProvider, + ), + ) + : Container( + alignment: Alignment.center, + color: Colors.black, + child: controllerProvider, + ), ); } @@ -344,6 +350,8 @@ class ChewieController extends ChangeNotifier { this.hideControlsTimer = defaultHideControlsTimer, this.controlsSafeAreaMinimum = EdgeInsets.zero, this.pauseOnBackgroundTap = false, + this.swipeToExitFullscreen = true, + this.swipeThreshold = 300, }) : assert( playbackSpeeds.every((speed) => speed > 0), 'The playbackSpeeds values must all be greater than 0', @@ -403,6 +411,8 @@ class ChewieController extends ChangeNotifier { )? routePageBuilder, bool? pauseOnBackgroundTap, + bool? swipeToExitFullscreen, + double? swipeThreshold, }) { return ChewieController( draggableProgressBar: draggableProgressBar ?? this.draggableProgressBar, @@ -467,6 +477,9 @@ class ChewieController extends ChangeNotifier { progressIndicatorDelay: progressIndicatorDelay ?? this.progressIndicatorDelay, pauseOnBackgroundTap: pauseOnBackgroundTap ?? this.pauseOnBackgroundTap, + swipeToExitFullscreen: + swipeToExitFullscreen ?? this.swipeToExitFullscreen, + swipeThreshold: swipeThreshold ?? this.swipeThreshold, ); } @@ -639,6 +652,13 @@ class ChewieController extends ChangeNotifier { /// Defines if the player should pause when the background is tapped final bool pauseOnBackgroundTap; + /// Defines if the player allows swipe to exit fullscreen + final bool swipeToExitFullscreen; + + /// Defines the minimum velocity threshold for swipe to exit fullscreen gesture + /// The velocity is measured in pixels per second + final double swipeThreshold; + static ChewieController of(BuildContext context) { final chewieControllerProvider = context .dependOnInheritedWidgetOfExactType()!;