diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index 35ca49d92f..c655ffe530 100644 --- a/packages/flutter/lib/src/widgets/scrollable.dart +++ b/packages/flutter/lib/src/widgets/scrollable.dart @@ -166,8 +166,7 @@ abstract class ScrollableState extends State { setState(() { _scrollOffset = newScrollOffset; }); - if (config.onScroll != null) - config.onScroll(_scrollOffset); + dispatchOnScroll(); } Future scrollTo(double newScrollOffset, { Duration duration, Curve curve: ease }) { @@ -200,6 +199,12 @@ abstract class ScrollableState extends State { return _startToEndAnimation(); } + // Derived classes can override this method and call super.dispatchOnScroll() + void dispatchOnScroll() { + if (config.onScroll != null) + config.onScroll(_scrollOffset); + } + double _scrollVelocity(ui.Offset velocity) { double scrollVelocity = config.scrollDirection == ScrollDirection.horizontal ? -velocity.dx