Unverified Commit cec14574 authored by xubaolin's avatar xubaolin Committed by GitHub

fix a DraggableScrollableSheet bug (#89335)

parent 1745402d
...@@ -466,6 +466,13 @@ class _DraggableScrollableSheetScrollPosition ...@@ -466,6 +466,13 @@ class _DraggableScrollableSheetScrollPosition
} }
} }
@override
void dispose() {
// Stop the animation before dispose.
_ballisticCancelCallback?.call();
super.dispose();
}
@override @override
void goBallistic(double velocity) { void goBallistic(double velocity) {
if (velocity == 0.0 || if (velocity == 0.0 ||
......
...@@ -344,5 +344,23 @@ void main() { ...@@ -344,5 +344,23 @@ void main() {
]; ];
expect(notificationTypes, types); expect(notificationTypes, types);
}); });
testWidgets('Do not crash when remove the tree during animation.', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/89214
await tester.pumpWidget(_boilerplate(
null,
onScrollNotification: (ScrollNotification notification) {
return false;
},
));
await tester.flingFrom(const Offset(0, 325), const Offset(0, 325), 200);
// The animation is running.
await tester.pumpWidget(const SizedBox.shrink());
expect(tester.takeException(), isNull);
});
} }
} }
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