diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index a5e7460435..20ef8ac28b 100644 --- a/packages/flutter/lib/src/widgets/scrollable.dart +++ b/packages/flutter/lib/src/widgets/scrollable.dart @@ -163,6 +163,14 @@ abstract class Scrollable extends StatefulComponent { 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(); } @@ -185,11 +193,7 @@ abstract class Scrollable extends StatefulComponent { } 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(); @@ -566,7 +570,7 @@ class PageableList extends ScrollableList { .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 * itemExtent) .clamp(_snapScrollOffset(scrollOffset - itemExtent / 2.0),