Fix stretch recede edge case (#90629)

This commit is contained in:
Kate Lovett 2021-09-23 17:33:05 -05:00 committed by GitHub
parent 115b953559
commit ca1dbb949e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 7 deletions

View File

@ -700,8 +700,7 @@ class _StretchingOverscrollIndicatorState extends State<StretchingOverscrollIndi
}
}
}
} else if (notification is ScrollEndNotification && notification.dragDetails != null
|| notification is ScrollUpdateNotification && notification.dragDetails != null) {
} else if (notification is ScrollEndNotification || notification is ScrollUpdateNotification) {
_stretchController.scrollEnd();
}
_lastNotification = notification;

View File

@ -97,7 +97,7 @@ void main() {
expect(box3.localToGlobal(Offset.zero).dy, greaterThan(510.0));
await expectLater(
find.byType(CustomScrollView),
matchesGoldenFile('overscroll_stretch.vertical.top.png'),
matchesGoldenFile('overscroll_stretch.vertical.start.stretched.png'),
);
await gesture.up();
@ -110,7 +110,11 @@ void main() {
// Jump to end of the list
controller.jumpTo(controller.position.maxScrollExtent);
await tester.pumpAndSettle();
expect(controller.offset, 150.0);
expect(box1.localToGlobal(Offset.zero).dy, -150.0);
expect(box2.localToGlobal(Offset.zero).dy, 100.0);
expect(box3.localToGlobal(Offset.zero).dy, 350.0);
await expectLater(
find.byType(CustomScrollView),
matchesGoldenFile('overscroll_stretch.vertical.end.png'),
@ -125,8 +129,16 @@ void main() {
expect(box3.localToGlobal(Offset.zero).dy, lessThan(350.0));
await expectLater(
find.byType(CustomScrollView),
matchesGoldenFile('overscroll_stretch.vertical.bottom.png'),
matchesGoldenFile('overscroll_stretch.vertical.end.stretched.png'),
);
await gesture.up();
await tester.pumpAndSettle();
// Stretch released back
expect(box1.localToGlobal(Offset.zero).dy, -150.0);
expect(box2.localToGlobal(Offset.zero).dy, 100.0);
expect(box3.localToGlobal(Offset.zero).dy, 350.0);
});
testWidgets('Stretch overscroll works in reverse - vertical', (WidgetTester tester) async {
@ -162,7 +174,7 @@ void main() {
);
});
testWidgets('Stretch overscroll horizontally', (WidgetTester tester) async {
testWidgets('Stretch overscroll works in reverse - horizontal', (WidgetTester tester) async {
final Key box1Key = UniqueKey();
final Key box2Key = UniqueKey();
final Key box3Key = UniqueKey();
@ -235,7 +247,7 @@ void main() {
expect(box3.localToGlobal(Offset.zero).dx, greaterThan(610.0));
await expectLater(
find.byType(CustomScrollView),
matchesGoldenFile('overscroll_stretch.horizontal.left.png'),
matchesGoldenFile('overscroll_stretch.horizontal.start.stretched.png'),
);
await gesture.up();
@ -248,7 +260,11 @@ void main() {
// Jump to end of the list
controller.jumpTo(controller.position.maxScrollExtent);
await tester.pumpAndSettle();
expect(controller.offset, 100.0);
expect(box1.localToGlobal(Offset.zero).dx, -100.0);
expect(box2.localToGlobal(Offset.zero).dx, 200.0);
expect(box3.localToGlobal(Offset.zero).dx, 500.0);
await expectLater(
find.byType(CustomScrollView),
matchesGoldenFile('overscroll_stretch.horizontal.end.png'),
@ -263,8 +279,16 @@ void main() {
expect(box3.localToGlobal(Offset.zero).dx, lessThan(500.0));
await expectLater(
find.byType(CustomScrollView),
matchesGoldenFile('overscroll_stretch.horizontal.right.png'),
matchesGoldenFile('overscroll_stretch.horizontal.end.stretched.png'),
);
await gesture.up();
await tester.pumpAndSettle();
// Stretch released back
expect(box1.localToGlobal(Offset.zero).dx, -100.0);
expect(box2.localToGlobal(Offset.zero).dx, 200.0);
expect(box3.localToGlobal(Offset.zero).dx, 500.0);
});
testWidgets('Disallow stretching overscroll', (WidgetTester tester) async {