diff --git a/packages/flutter/lib/src/fn3/scrollable.dart b/packages/flutter/lib/src/fn3/scrollable.dart index 2bf05d299a..b5429c8c42 100644 --- a/packages/flutter/lib/src/fn3/scrollable.dart +++ b/packages/flutter/lib/src/fn3/scrollable.dart @@ -158,6 +158,14 @@ abstract class ScrollableState extends State { return scrollTo(newScrollOffset, duration: duration, curve: curve); } + void fling(Offset velocity) { + if (velocity != Offset.zero) { + _startToEndAnimation(velocity: _scrollVelocity(velocity)); + } else if (!_toEndAnimation.isAnimating && (_toOffsetAnimation == null || !_toOffsetAnimation.isAnimating)) { + settleScrollOffset(); + } + } + void settleScrollOffset() { _startToEndAnimation(); } @@ -180,11 +188,7 @@ abstract class ScrollableState extends State { } void _handleDragEnd(Offset velocity) { - if (velocity != Offset.zero) { - _startToEndAnimation(velocity: _scrollVelocity(velocity)); - } else if (!_toEndAnimation.isAnimating && (_toOffsetAnimation == null || !_toOffsetAnimation.isAnimating)) { - settleScrollOffset(); - } + fling(velocity); } final List _listeners = new List(); @@ -520,7 +524,7 @@ class PageableListState extends ScrollableListState> { .clamp(scrollBehavior.minScrollOffset, scrollBehavior.maxScrollOffset); } - void _handleDragEnd(sky.Offset velocity) { + void fling(sky.Offset velocity) { double scrollVelocity = _scrollVelocity(velocity); double newScrollOffset = _snapScrollOffset(scrollOffset + scrollVelocity.sign * config.itemExtent) .clamp(_snapScrollOffset(scrollOffset - config.itemExtent / 2.0),