Start refresh while bouncing back to 0.0 from overscroll on iOS (#18012)
This commit is contained in:
parent
026c89835f
commit
62e87c8e6f
@ -226,6 +226,12 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
|
||||
_checkDragOffset(notification.metrics.viewportDimension);
|
||||
}
|
||||
}
|
||||
if (_mode == _RefreshIndicatorMode.armed && notification.dragDetails == null) {
|
||||
// On iOS start the refresh when the Scrollable bounces back from the
|
||||
// overscroll (ScrollNotification indicating this don't have dragDetails
|
||||
// because the scroll activity is not directly triggered by a drag).
|
||||
_show();
|
||||
}
|
||||
} else if (notification is OverscrollNotification) {
|
||||
if (_mode == _RefreshIndicatorMode.drag || _mode == _RefreshIndicatorMode.armed) {
|
||||
_dragOffset -= notification.overscroll / 2.0;
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@ -378,4 +379,41 @@ void main() {
|
||||
expect(refreshCalled, true);
|
||||
expect(tester.takeException(), isFlutterError);
|
||||
});
|
||||
|
||||
testWidgets('Refresh starts while scroll view moves back to 0.0 after overscroll on iOS', (WidgetTester tester) async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
||||
refreshCalled = false;
|
||||
double lastScrollOffset;
|
||||
final ScrollController controller = new ScrollController();
|
||||
|
||||
await tester.pumpWidget(
|
||||
new MaterialApp(
|
||||
home: new RefreshIndicator(
|
||||
onRefresh: refresh,
|
||||
child: new ListView(
|
||||
controller: controller,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
children: <String>['A', 'B', 'C', 'D', 'E', 'F'].map((String item) {
|
||||
return new SizedBox(
|
||||
height: 200.0,
|
||||
child: new Text(item),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.fling(find.text('A'), const Offset(0.0, 300.0), 1000.0);
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
expect(lastScrollOffset = controller.offset, lessThan(0.0));
|
||||
expect(refreshCalled, isFalse);
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
expect(controller.offset, greaterThan(lastScrollOffset));
|
||||
expect(controller.offset, lessThan(0.0));
|
||||
expect(refreshCalled, isTrue);
|
||||
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user