Commit 477a54c3 authored by Collin Jackson's avatar Collin Jackson

Allow derived classes of Scrollable to listen for scroll events

parent 90971695
...@@ -166,8 +166,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> { ...@@ -166,8 +166,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
setState(() { setState(() {
_scrollOffset = newScrollOffset; _scrollOffset = newScrollOffset;
}); });
if (config.onScroll != null) dispatchOnScroll();
config.onScroll(_scrollOffset);
} }
Future scrollTo(double newScrollOffset, { Duration duration, Curve curve: ease }) { Future scrollTo(double newScrollOffset, { Duration duration, Curve curve: ease }) {
...@@ -200,6 +199,12 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> { ...@@ -200,6 +199,12 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
return _startToEndAnimation(); 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(ui.Offset velocity) {
double scrollVelocity = config.scrollDirection == ScrollDirection.horizontal double scrollVelocity = config.scrollDirection == ScrollDirection.horizontal
? -velocity.dx ? -velocity.dx
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment