@@ -409,6 +409,11 @@ class DragHandleAutoScroller {
409
409
final scrollPosition = _getScrollPosition ();
410
410
final currentScrollOffset = scrollPosition.pixels;
411
411
412
+ // The offset calculation below does not work correctly in custom scroll view with sliver header
413
+ // and causes overscroll so for now clamp the offset.
414
+ final max = scrollPosition.maxScrollExtent;
415
+ final min = scrollPosition.minScrollExtent;
416
+
412
417
if (offsetInViewport.dy < _dragAutoScrollBoundary.leading) {
413
418
// The offset is above the leading boundary. We need to scroll up
414
419
editorGesturesLog.fine ("The scrollable needs to scroll up to make offset visible." );
@@ -417,8 +422,8 @@ class DragHandleAutoScroller {
417
422
// at the top edge of the scrollable, so we can't scroll further up.
418
423
if (currentScrollOffset > 0.0 ) {
419
424
// Jump to the position where the offset sits at the leading boundary.
420
- scrollPosition.jumpTo (
421
- currentScrollOffset + (offsetInViewport.dy - _dragAutoScrollBoundary.leading),
425
+ scrollPosition.jumpTo ((
426
+ currentScrollOffset + (offsetInViewport.dy - _dragAutoScrollBoundary.leading). clamp (min, max)) ,
422
427
);
423
428
}
424
429
} else if (offsetInViewport.dy > _getViewportBox ().size.height - _dragAutoScrollBoundary.trailing) {
@@ -429,7 +434,7 @@ class DragHandleAutoScroller {
429
434
// distance below. Scroll to where the offset sits at the trailing boundary.
430
435
final jumpDeltaToShowOffset =
431
436
offsetInViewport.dy + _dragAutoScrollBoundary.trailing - _getViewportBox ().size.height;
432
- scrollPosition.jumpTo (currentScrollOffset + jumpDeltaToShowOffset);
437
+ scrollPosition.jumpTo (( currentScrollOffset + jumpDeltaToShowOffset). clamp (min, max) );
433
438
}
434
439
}
435
440
}
0 commit comments