mirror of
https://github.com/flutter/flutter
synced 2024-09-20 00:32:02 +00:00
Reduce refresh indicator pull-down distance and update related tests (#69783)
Co-authored-by: altherat <contact@altherat.com>
This commit is contained in:
parent
2f3cccc4f5
commit
300e1df737
|
@ -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) {
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue