@@ -248,6 +248,25 @@ class _ImageLightboxPageState extends State<_ImageLightboxPage> {
248
248
}
249
249
}
250
250
251
+ class VideoDurationLabel extends StatelessWidget {
252
+ const VideoDurationLabel (this .duration, {super .key});
253
+
254
+ final Duration duration;
255
+
256
+ static String _formatDuration (Duration value) {
257
+ final hours = value.inHours.toString ().padLeft (2 , '0' );
258
+ final minutes = value.inMinutes.remainder (60 ).toString ().padLeft (2 , '0' );
259
+ final seconds = value.inSeconds.remainder (60 ).toString ().padLeft (2 , '0' );
260
+ return '${hours == '00' ? '' : '$hours :' }$minutes :$seconds ' ;
261
+ }
262
+
263
+ @override
264
+ Widget build (BuildContext context) {
265
+ return Text (_formatDuration (duration),
266
+ style: const TextStyle (color: Colors .white));
267
+ }
268
+ }
269
+
251
270
class _VideoPositionSliderControl extends StatefulWidget {
252
271
final VideoPlayerController controller;
253
272
@@ -293,22 +312,14 @@ class _VideoPositionSliderControlState extends State<_VideoPositionSliderControl
293
312
});
294
313
}
295
314
296
- static String _formatDuration (Duration value) {
297
- final hours = value.inHours.toString ().padLeft (2 , '0' );
298
- final minutes = value.inMinutes.remainder (60 ).toString ().padLeft (2 , '0' );
299
- final seconds = value.inSeconds.remainder (60 ).toString ().padLeft (2 , '0' );
300
- return '${hours == '00' ? '' : '$hours :' }$minutes :$seconds ' ;
301
- }
302
-
303
315
@override
304
316
Widget build (BuildContext context) {
305
317
final currentPosition = _isSliderDragging
306
318
? _sliderValue
307
319
: widget.controller.value.position;
308
320
309
321
return Row (children: [
310
- Text (_formatDuration (currentPosition),
311
- style: const TextStyle (color: Colors .white)),
322
+ VideoDurationLabel (currentPosition),
312
323
Expanded (
313
324
child: Slider (
314
325
value: currentPosition.inMilliseconds.toDouble (),
@@ -337,8 +348,7 @@ class _VideoPositionSliderControlState extends State<_VideoPositionSliderControl
337
348
},
338
349
),
339
350
),
340
- Text (_formatDuration (widget.controller.value.duration),
341
- style: const TextStyle (color: Colors .white)),
351
+ VideoDurationLabel (widget.controller.value.duration),
342
352
]);
343
353
}
344
354
}
0 commit comments