Make updateUserScrollDirection protected (#13850)

This commit is contained in:
Ian Hickson 2018-01-08 21:39:16 -08:00 committed by GitHub
parent 61a8132ea9
commit ce83f4fbe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -165,7 +165,7 @@ class ScrollPositionWithSingleContext extends ScrollPosition implements ScrollAc
/// Set [userScrollDirection] to the given value.
///
/// If this changes the value, then a [UserScrollNotification] is dispatched.
@visibleForTesting
@protected
void updateUserScrollDirection(ScrollDirection value) {
assert(value != null);
if (userScrollDirection == value)

View File

@ -178,6 +178,10 @@ class LinkedScrollPosition extends ScrollPositionWithSingleContext {
assert(localOverscroll == 0.0 || (beforeOverscroll == 0.0 && afterOverscroll == 0.0));
}
void _userMoved(ScrollDirection direction) {
updateUserScrollDirection(direction);
}
LinkedScrollActivity link(LinkedScrollPosition driver) {
if (this.activity is! LinkedScrollActivity)
beginActivity(new LinkedScrollActivity(this));
@ -239,7 +243,7 @@ class LinkedScrollActivity extends ScrollActivity {
if (driver.userScrollDirection != commonDirection)
commonDirection = ScrollDirection.idle;
}
delegate.updateUserScrollDirection(commonDirection);
delegate._userMoved(commonDirection);
return delegate.setPixels(delegate.pixels + delta);
}

View File

@ -187,7 +187,7 @@ void main() {
verifyPaintPosition(key3, const Offset(0.0, 0.0), true);
position.animateTo(bigHeight + delegate.maxExtent * 1.9, curve: Curves.linear, duration: const Duration(minutes: 1));
position.updateUserScrollDirection(ScrollDirection.forward);
position.updateUserScrollDirection(ScrollDirection.forward); // ignore: invalid_use_of_protected_member
await tester.pumpAndSettle(const Duration(milliseconds: 1000));
verifyPaintPosition(key1, const Offset(0.0, 0.0), false);
verifyPaintPosition(key2, const Offset(0.0, 0.0), true);