diff --git a/packages/flutter/lib/src/material/refresh_indicator.dart b/packages/flutter/lib/src/material/refresh_indicator.dart index 1433504186..6560cd34a2 100644 --- a/packages/flutter/lib/src/material/refresh_indicator.dart +++ b/packages/flutter/lib/src/material/refresh_indicator.dart @@ -258,7 +258,7 @@ class RefreshIndicatorState extends State 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) { diff --git a/packages/flutter/test/material/refresh_indicator_test.dart b/packages/flutter/test/material/refresh_indicator_test.dart index fa1415629b..073aeaa6d9 100644 --- a/packages/flutter/test/material/refresh_indicator_test.dart +++ b/packages/flutter/test/material/refresh_indicator_test.dart @@ -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 [ + 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(