Allow derived classes of Scrollable to listen for scroll events
This commit is contained in:
parent
909716956e
commit
477a54c375
@ -166,8 +166,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
|
||||
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<T extends Scrollable> extends State<T> {
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user