Commit 6a9ea16e authored by Adam Barth's avatar Adam Barth Committed by GitHub

jumpTo during a user drag shouldn't assert (#8384)

Fixes #8380
parent 718859ad
...@@ -629,8 +629,11 @@ class DragScrollActivity extends ScrollActivity { ...@@ -629,8 +629,11 @@ class DragScrollActivity extends ScrollActivity {
@override @override
Notification createScrollEndNotification(AbstractScrollState scrollable) { Notification createScrollEndNotification(AbstractScrollState scrollable) {
assert(_lastDetails is DragEndDetails); // We might not have DragEndDetails yet if we're being called from beginActivity.
return new ScrollEndNotification(scrollable: scrollable, dragDetails: _lastDetails); return new ScrollEndNotification(
scrollable: scrollable,
dragDetails: _lastDetails is DragEndDetails ? _lastDetails : null
);
} }
@override @override
......
...@@ -115,4 +115,57 @@ void main() { ...@@ -115,4 +115,57 @@ void main() {
expect(log, equals(<String>['Massachusetts'])); expect(log, equals(<String>['Massachusetts']));
log.clear(); log.clear();
}); });
testWidgets('Can jumpTo during drag', (WidgetTester tester) async {
final List<Type> log = <Type>[];
final ScrollController controller = new ScrollController();
await tester.pumpWidget(new NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification notification) {
log.add(notification.runtimeType);
return false;
},
child: new ListView(
controller: controller,
children: kStates.map<Widget>((String state) {
return new Container(
height: 200.0,
child: new Text(state),
);
}).toList(),
),
));
expect(log, isEmpty);
TestGesture gesture = await tester.startGesture(const Point(100.0, 100.0));
await gesture.moveBy(const Offset(0.0, -100.0));
expect(log, equals(<Type>[
ScrollStartNotification,
UserScrollNotification,
ScrollUpdateNotification,
]));
log.clear();
await tester.pump();
controller.jumpTo(550.0);
expect(controller.offset, equals(550.0));
expect(log, equals(<Type>[
ScrollEndNotification,
UserScrollNotification,
ScrollStartNotification,
ScrollUpdateNotification,
ScrollEndNotification,
]));
log.clear();
await tester.pump();
await gesture.moveBy(const Offset(0.0, -100.0));
expect(controller.offset, equals(550.0));
expect(log, isEmpty);
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment