@@ -22,6 +22,7 @@ class MovieCell extends StatefulWidget {
22
22
23
23
class _MovieCellState extends State <MovieCell > {
24
24
bool isPlayerVisible = false ;
25
+ BetterPlayer ? betterPlayer;
25
26
26
27
@override
27
28
Widget build (BuildContext context) {
@@ -32,32 +33,9 @@ class _MovieCellState extends State<MovieCell> {
32
33
crossAxisAlignment: CrossAxisAlignment .stretch,
33
34
children: [
34
35
if (isPlayerVisible)
35
- createBetterPlayer ()
36
+ createBetterPlayer () ?? nonePlayer ()
36
37
else
37
- SizedBox (
38
- height: 80 ,
39
- child:
40
- GestureDetector (
41
- onTap: () {
42
- setState (() {
43
- isPlayerVisible = true ;
44
- });
45
- },
46
- child: const Center (
47
- child: Row (
48
- mainAxisSize: MainAxisSize .min,
49
- children: [
50
- Icon (Icons .play_circle_fill, size: 45 , color: Colors .white),
51
- SizedBox (width: 5 ),
52
- Text (
53
- "Streaming Play" ,
54
- style: TextStyle (fontSize: 10 , color: Colors .white),
55
- ),
56
- ],
57
- ),
58
- ),
59
- ),
60
- ),
38
+ nonePlayer (),
61
39
const SizedBox (height: 16 ),
62
40
Row (
63
41
crossAxisAlignment: CrossAxisAlignment .start,
@@ -93,7 +71,37 @@ class _MovieCellState extends State<MovieCell> {
93
71
);
94
72
}
95
73
96
- Widget createBetterPlayer () {
74
+ Widget nonePlayer () {
75
+ return SizedBox (
76
+ height: 80 ,
77
+ child: GestureDetector (
78
+ onTap: () {
79
+ setState (() {
80
+ isPlayerVisible = true ;
81
+ });
82
+ },
83
+ child: const Center (
84
+ child: Row (
85
+ mainAxisSize: MainAxisSize .min,
86
+ children: [
87
+ Icon (Icons .play_circle_fill, size: 45 , color: Colors .white),
88
+ SizedBox (width: 5 ),
89
+ Text (
90
+ "Streaming Play" ,
91
+ style: TextStyle (fontSize: 10 , color: Colors .white),
92
+ ),
93
+ ],
94
+ ),
95
+ ),
96
+ ),
97
+ );
98
+ }
99
+
100
+ Widget ? createBetterPlayer () {
101
+ if (betterPlayer != null ) {
102
+ return betterPlayer;
103
+ }
104
+
97
105
const betterPlayerConfiguration = BetterPlayerConfiguration (
98
106
aspectRatio: 16 / 9 ,
99
107
fit: BoxFit .contain,
@@ -121,7 +129,8 @@ class _MovieCellState extends State<MovieCell> {
121
129
drmConfiguration: drmConfig);
122
130
123
131
betterPlayerController.setupDataSource (betterPlayerDataSource);
124
- return BetterPlayer (controller: betterPlayerController);
132
+ betterPlayer = BetterPlayer (controller: betterPlayerController);
133
+ return betterPlayer;
125
134
}
126
135
127
136
String movieInformation () {
0 commit comments