Skip to content

Conversation

@bleroux
Copy link
Contributor

@bleroux bleroux commented Apr 25, 2022

Description

DraggableScrollableController.animateTo creates new AnimationControllers but don’t dispose them. It creates new AnimationControllers using a vsync it gets from the following call vsync: _attachedController!.position.context.vsync, doing so the AnimationController is attached to a ScrollableState widget.

This PR allows DraggableScrollableController to 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.dart

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard bot added f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. labels Apr 25, 2022
@bleroux bleroux requested a review from dnfield April 25, 2022 12:42
Copy link
Contributor

@dnfield dnfield left a 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>{};
Copy link
Contributor

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 {
Copy link
Member

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

@fluttergithubbot fluttergithubbot merged commit bc7d3bb into flutter:master Apr 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 26, 2022
@bleroux bleroux deleted the draggable_scrollable_controller_leak branch April 26, 2022 11:29
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 28, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 28, 2022
egramond pushed a commit to egramond/flutter that referenced this pull request May 5, 2022
@dnfield
Copy link
Contributor

dnfield commented May 16, 2022

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.

@dnfield
Copy link
Contributor

dnfield commented May 16, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DraggableScrollableSheet throws an exception when disposed while being animated by DraggableScrollableController.animateTo

4 participants