-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fix DraggableScrollableController.animateTo leaks Ticker #102504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix DraggableScrollableController.animateTo leaks Ticker #102504
Conversation
dnfield
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nit
| /// constraints provided to an attached sheet change. | ||
| class DraggableScrollableController extends ChangeNotifier { | ||
| _DraggableScrollableSheetScrollController? _attachedController; | ||
| Set<AnimationController> _animationControllers = <AnimationController>{}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: make this final and use .clear() in dispose below.
| expect(controller.size, isNotNull); | ||
| }); | ||
|
|
||
| testWidgets('DraggableScrollableController.animateTo should not leak Ticker', (WidgetTester tester) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add a comment for the relation issue
// Regression test for #102483
|
This seems to have caused a few regressions on internal tests. It looks like in some cases where the modal was getting dismissed, it's now not. |
|
That is somewhat speculative on my part, since I can only see in a golden file test that the image is a shade darker above the sheet |
Description
DraggableScrollableController.animateTocreates new AnimationControllers but don’t dispose them. It creates new AnimationControllers using avsyncit gets from the following callvsync: _attachedController!.position.context.vsync,doing so the AnimationController is attached to a ScrollableState widget.This PR allows
DraggableScrollableControllerto manage the AnimationControllers it created and to register a callback called when the ScollableState is disposed (more precisely when the Position object is detached from the ScrollableState).Related Issue
Fixes #102483
Tests
Add one test in
draggable_scrollable_sheet_test.dartPre-launch Checklist
///).