@@ -33,66 +33,67 @@ class PlayerWithControls extends StatelessWidget {
3333 ChewieController chewieController,
3434 BuildContext context,
3535 ) {
36- final playerNotifier =
37- Provider .of <PlayerNotifier >(context, listen: false );
38- return InteractiveViewer (
39- transformationController: chewieController.transformationController,
40- maxScale: chewieController.maxScale,
41- panEnabled: chewieController.zoomAndPan,
42- scaleEnabled: chewieController.zoomAndPan,
43- onInteractionUpdate: chewieController.zoomAndPan
44- ? (_) => playerNotifier.hideStuff = true
45- : null ,
46- onInteractionEnd: chewieController.zoomAndPan
47- ? (_) => playerNotifier.hideStuff = false
48- : null ,
49- child: Stack (
50- children: [
51- if (chewieController.placeholder != null )
52- chewieController.placeholder! ,
53- Center (
54- child: AspectRatio (
55- aspectRatio: chewieController.aspectRatio ??
56- chewieController.videoPlayerController.value.aspectRatio,
57- child: VideoPlayer (chewieController.videoPlayerController),
58- ),
36+ final playerNotifier = Provider .of <PlayerNotifier >(context, listen: false );
37+ final child = Stack (
38+ children: [
39+ if (chewieController.placeholder != null ) chewieController.placeholder! ,
40+ Center (
41+ child: AspectRatio (
42+ aspectRatio: chewieController.aspectRatio ??
43+ chewieController.videoPlayerController.value.aspectRatio,
44+ child: VideoPlayer (chewieController.videoPlayerController),
5945 ),
60- if (chewieController.overlay != null ) chewieController.overlay ! ,
61- if (Theme . of (context).platform != TargetPlatform .iOS)
62- Consumer < PlayerNotifier >(
63- builder : (
64- BuildContext context,
65- PlayerNotifier notifier ,
66- Widget ? widget ,
67- ) =>
68- Visibility (
69- visible : ! notifier.hideStuff,
70- child : AnimatedOpacity (
71- opacity : notifier.hideStuff ? 0.0 : 0.8 ,
72- duration : const Duration (
73- milliseconds : 250 ,
74- ) ,
75- child : const DecoratedBox (
76- decoration : BoxDecoration (color : Colors .black54),
77- child : SizedBox . expand ( ),
78- ),
46+ ) ,
47+ if (chewieController.overlay != null ) chewieController.overlay ! ,
48+ if ( Theme . of (context).platform != TargetPlatform .iOS)
49+ Consumer < PlayerNotifier > (
50+ builder : (
51+ BuildContext context ,
52+ PlayerNotifier notifier ,
53+ Widget ? widget,
54+ ) =>
55+ Visibility (
56+ visible : ! notifier.hideStuff,
57+ child : AnimatedOpacity (
58+ opacity : notifier.hideStuff ? 0.0 : 0.8 ,
59+ duration : const Duration (
60+ milliseconds : 250 ,
61+ ),
62+ child : const DecoratedBox (
63+ decoration : BoxDecoration (color : Colors .black54 ),
64+ child : SizedBox . expand ( ),
7965 ),
8066 ),
8167 ),
82- if ( ! chewieController.isFullScreen)
83- buildControls (context, chewieController)
84- else
85- SafeArea (
86- bottom : false ,
87- child : buildControls (context, chewieController) ,
88- ),
89- ] ,
90- ) ,
68+ ),
69+ if ( ! chewieController.isFullScreen )
70+ buildControls (context, chewieController)
71+ else
72+ SafeArea (
73+ bottom : false ,
74+ child : buildControls (context, chewieController ),
75+ ) ,
76+ ] ,
9177 );
78+
79+ if (chewieController.zoomAndPan || chewieController.transformationController != null ) {
80+ return InteractiveViewer (
81+ transformationController: chewieController.transformationController,
82+ maxScale: chewieController.maxScale,
83+ panEnabled: chewieController.zoomAndPan,
84+ scaleEnabled: chewieController.zoomAndPan,
85+ onInteractionUpdate:
86+ chewieController.zoomAndPan ? (_) => playerNotifier.hideStuff = true : null ,
87+ onInteractionEnd:
88+ chewieController.zoomAndPan ? (_) => playerNotifier.hideStuff = false : null ,
89+ child: child,
90+ );
91+ }
92+
93+ return child;
9294 }
9395
94- return LayoutBuilder (
95- builder: (BuildContext context, BoxConstraints constraints) {
96+ return LayoutBuilder (builder: (BuildContext context, BoxConstraints constraints) {
9697 return Center (
9798 child: SizedBox (
9899 height: constraints.maxHeight,
0 commit comments