@@ -58,10 +58,11 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
58
58
}
59
59
60
60
void _seekToRelativePosition (Offset globalPosition) {
61
- controller. seekTo ( context.calcRelativePosition (
61
+ final relativePosition = context.calcRelativePosition (
62
62
controller.value.duration,
63
63
globalPosition,
64
- ));
64
+ );
65
+ controller.seekTo (relativePosition ?? Duration .zero);
65
66
}
66
67
67
68
@override
@@ -74,6 +75,7 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
74
75
barHeight: widget.barHeight,
75
76
handleHeight: widget.handleHeight,
76
77
drawShadow: widget.drawShadow,
78
+ latestDraggableOffset: _latestDraggableOffset,
77
79
),
78
80
);
79
81
@@ -181,7 +183,7 @@ class _ProgressBarPainter extends CustomPainter {
181
183
final double barHeight;
182
184
final double handleHeight;
183
185
final bool drawShadow;
184
- final Duration draggableValue;
186
+ final Duration ? draggableValue;
185
187
186
188
@override
187
189
bool shouldRepaint (CustomPainter painter) {
@@ -205,8 +207,8 @@ class _ProgressBarPainter extends CustomPainter {
205
207
if (! value.isInitialized) {
206
208
return ;
207
209
}
208
- final double playedPartPercent = (draggableValue != Duration .zero
209
- ? draggableValue.inMilliseconds
210
+ final double playedPartPercent = (draggableValue != null
211
+ ? draggableValue! .inMilliseconds
210
212
: value.position.inMilliseconds) /
211
213
value.duration.inMilliseconds;
212
214
final double playedPart =
@@ -257,11 +259,11 @@ class _ProgressBarPainter extends CustomPainter {
257
259
}
258
260
259
261
extension RelativePositionExtensions on BuildContext {
260
- Duration calcRelativePosition (
262
+ Duration ? calcRelativePosition (
261
263
Duration videoDuration,
262
264
Offset ? globalPosition,
263
265
) {
264
- if (globalPosition == null ) return Duration .zero ;
266
+ if (globalPosition == null ) return null ;
265
267
final box = findRenderObject ()! as RenderBox ;
266
268
final Offset tapPos = box.globalToLocal (globalPosition);
267
269
final double relative = tapPos.dx / box.size.width;
0 commit comments