From 477a54c3758574768a2de0f68cea19f9ec87ae47 Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Mon, 12 Oct 2015 16:10:46 -0700 Subject: [PATCH] Allow derived classes of Scrollable to listen for scroll events --- packages/flutter/lib/src/widgets/scrollable.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index 310dd57a40..71723e6bc3 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