Reduce refresh indicator pull-down distance and update related tests (#69783)

Co-authored-by: altherat <contact@altherat.com>
This commit is contained in:
Lazy Llama 2020-11-05 05:34:10 +01:00 committed by GitHub
parent 2f3cccc4f5
commit 300e1df737
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 2 deletions

View file

@ -258,7 +258,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
}
} else if (notification is OverscrollNotification) {
if (_mode == _RefreshIndicatorMode.drag || _mode == _RefreshIndicatorMode.armed) {
_dragOffset = _dragOffset! - notification.overscroll / 2.0;
_dragOffset = _dragOffset! - notification.overscroll;
_checkDragOffset(notification.metrics.viewportDimension);
}
} else if (notification is ScrollEndNotification) {

View file

@ -225,7 +225,7 @@ void main() {
),
);
await tester.fling(find.text('X'), const Offset(0.0, 100.0), 1000.0);
await tester.fling(find.text('X'), const Offset(0.0, 50.0), 1000.0);
await tester.pump();
await tester.pump(const Duration(seconds: 1));
await tester.pump(const Duration(seconds: 1));
@ -233,6 +233,33 @@ void main() {
expect(refreshCalled, false);
});
testWidgets('RefreshIndicator - just enough', (WidgetTester tester) async {
refreshCalled = false;
await tester.pumpWidget(
MaterialApp(
home: RefreshIndicator(
onRefresh: refresh,
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
children: const <Widget>[
SizedBox(
height: 200.0,
child: Text('X'),
),
],
),
),
),
);
await tester.fling(find.text('X'), const Offset(0.0, 100.0), 1000.0);
await tester.pump();
await tester.pump(const Duration(seconds: 1));
await tester.pump(const Duration(seconds: 1));
await tester.pump(const Duration(seconds: 1));
expect(refreshCalled, true);
});
testWidgets('RefreshIndicator - show - slow', (WidgetTester tester) async {
refreshCalled = false;
await tester.pumpWidget(