Skip to content

Conversation

@MitchellGoodwin
Copy link
Contributor

@MitchellGoodwin MitchellGoodwin commented Jan 6, 2026

Fixes #179337 by moving the disposal of an animation controller outside of the didUpdate method flow. It was unnecessary to rebuild this controller on update, and was originally put there to follow the pattern of the other animations. However, unlike the other animations, this one is not chained to animations from outside of the transition's place in the tree, and was throwing exceptions from the ticker mixin in some cases.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: cupertino flutter/packages/flutter/cupertino repository labels Jan 6, 2026
@MitchellGoodwin MitchellGoodwin changed the title Sheet ticker Do not dispose CupertinoSheetTransition animation on update and throw ticker error Jan 6, 2026
@MitchellGoodwin MitchellGoodwin added the team-design Owned by Design Languages team label Jan 6, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes a ticker-related exception in CupertinoSheetTransition by adjusting the lifecycle of _stretchDragController. Moving its initialization to initState and disposal to dispose is the right approach to prevent issues during widget updates. The new test case provides good coverage for the fix. I have one suggestion to clean up some unused code in the test file.

Comment on lines 16 to 77
class _RebuildingPage extends StatefulWidget {
const _RebuildingPage({required this.scaffoldKey});

final GlobalKey scaffoldKey;

@override
_RebuildingPageState createState() => _RebuildingPageState();
}

class _RebuildingPageState extends State<_RebuildingPage> {
late int counter;

@override
void initState() {
super.initState();
counter = 0;
}

@override
Widget build(BuildContext context) {
return CupertinoApp(
home: CupertinoPageScaffold(
key: widget.scaffoldKey,
child: Center(
child: Column(
children: <Widget>[
const Text('Page 1'),
CupertinoButton(
onPressed: () {
Navigator.push<void>(
widget.scaffoldKey.currentContext!,
CupertinoSheetRoute<void>(
builder: (BuildContext context) {
return CupertinoPageScaffold(
child: Center(
child: Column(
children: <Widget>[
const Text('Page two'),
Text('Counter Value: $counter'),
CupertinoButton(
onPressed: () => setState(() {
counter++;
}),
child: const Text('Increase Count'),
),
],
),
),
);
},
),
);
},
child: const Text('Push Page 2'),
),
],
),
),
),
);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The _RebuildingPage widget and its state _RebuildingPageState appear to be unused in this test file. To improve code clarity and maintainability, it's best to remove this dead code. If it was added for debugging purposes, it should be removed before merging.


final newAnimation = AnimationController(vsync: const TestVSync());

// Should not throw an exception.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive by nit, we can probably assert this with expect(tester.takeException(), isNull);
since otherwise this would throw an AssertionError ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, except for minor comments

reverseCurve: Curves.easeInToLinear,
parent: widget.secondaryRouteAnimation,
);
_stretchDragController = AnimationController(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do a _stretchDragController.reset() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. I don't see a need to reseting the value and casing the jump on this update flow. I'd think we would want to hold the old status and value if it's non-zero.


final newAnimation = AnimationController(vsync: const TestVSync());

// Should not throw an exception.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@MitchellGoodwin MitchellGoodwin added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 7, 2026
@auto-submit auto-submit bot added this pull request to the merge queue Jan 8, 2026
Merged via the queue into flutter:master with commit c2b3ae1 Jan 8, 2026
71 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 8, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 9, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 9, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 9, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 9, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 10, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 10, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels. team-design Owned by Design Languages team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CupertinoSheetTransitionState creates multiple tickers / AnimationController dispose does not free tickers.

3 participants