-
Notifications
You must be signed in to change notification settings - Fork 3.5k
*Breaking change* Deprecate CurvedAnimation.reverseCurve in favor of AsymmetricCurvedAnimation
#13347
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
base: main
Are you sure you want to change the base?
*Breaking change* Deprecate CurvedAnimation.reverseCurve in favor of AsymmetricCurvedAnimation
#13347
Changes from all commits
f17a81a
ad165a8
e163991
2321bc7
1a7754e
ce8adfe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,112 @@ | ||||||||||||||||||
| --- | ||||||||||||||||||
| title: Deprecate `CurvedAnimation.reverseCurve` in favor of `AsymmetricCurvedAnimation` | ||||||||||||||||||
| description: >- | ||||||||||||||||||
| CurvedAnimation is becoming a single-curve animation. | ||||||||||||||||||
| Use AsymmetricCurvedAnimation for different curves in | ||||||||||||||||||
| the forward and reverse directions. | ||||||||||||||||||
| --- | ||||||||||||||||||
|
|
||||||||||||||||||
| {% render "docs/breaking-changes.md" %} | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Summary | ||||||||||||||||||
|
|
||||||||||||||||||
| [`CurvedAnimation`][]'s [`reverseCurve`][] field has been deprecated. | ||||||||||||||||||
|
|
||||||||||||||||||
| To use distinct curves for forward and reverse directions, | ||||||||||||||||||
| switch from [`CurvedAnimation`][] to [`AsymmetricCurvedAnimation`][]. | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Background | ||||||||||||||||||
|
|
||||||||||||||||||
| To support its [`reverseCurve`][] functionality, | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The link
Suggested change
|
||||||||||||||||||
| `CurvedAnimation` had to add listeners to its [`parent`][] | ||||||||||||||||||
| to keep track of its direction. | ||||||||||||||||||
| If you forget to call the [`dispose`][] method when you're done, | ||||||||||||||||||
| those listeners would leak. | ||||||||||||||||||
|
|
||||||||||||||||||
| However, most animations use the same curve for the forward | ||||||||||||||||||
| and reverse directions. | ||||||||||||||||||
|
|
||||||||||||||||||
| To make the common case leak-proof, `CurvedAnimation`'s | ||||||||||||||||||
| `reverseCurve` functionality is moving to a separate class: | ||||||||||||||||||
| [`AsymmetricCurvedAnimation`][]. | ||||||||||||||||||
|
|
||||||||||||||||||
| In the future, the `reverseCurve` field will be removed from | ||||||||||||||||||
| `CurvedAnimation`. | ||||||||||||||||||
|
|
||||||||||||||||||
| :::note | ||||||||||||||||||
| Until the deprecation period is over, you must continue to | ||||||||||||||||||
| call [`dispose`][] on [`CurvedAnimation`]. If you switch to [`AsymmetricCurvedAnimation`][], you must always call its | ||||||||||||||||||
| [`dispose`][] method to clean up its active direction listeners. | ||||||||||||||||||
|
Comment on lines
+37
to
+39
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line exceeds the 80-character limit for semantic line breaks (it is 114 characters long). Additionally, the first Let's wrap the text to adhere to semantic line breaks and use the correct link reference.
Suggested change
|
||||||||||||||||||
| ::: | ||||||||||||||||||
|
adil192 marked this conversation as resolved.
|
||||||||||||||||||
|
|
||||||||||||||||||
| ## Migration guide | ||||||||||||||||||
|
|
||||||||||||||||||
| If you need [`CurvedAnimation`][]'s [`reverseCurve`][] field, | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||
| switch from [`CurvedAnimation`][] to [`AsymmetricCurvedAnimation`][]. | ||||||||||||||||||
|
|
||||||||||||||||||
| Code before migration: | ||||||||||||||||||
|
|
||||||||||||||||||
| ```dart | ||||||||||||||||||
| // This doesn't use `reverseCurve` so it stays as `CurvedAnimation`: | ||||||||||||||||||
| final oneCurve = CurvedAnimation( | ||||||||||||||||||
| parent: _animationController, | ||||||||||||||||||
| curve: Curves.easeIn, | ||||||||||||||||||
| ); | ||||||||||||||||||
|
|
||||||||||||||||||
| // This uses `reverseCurve` so migrate to `AsymmetricCurvedAnimation`: | ||||||||||||||||||
| final twoCurves = CurvedAnimation( | ||||||||||||||||||
| parent: _animationController, | ||||||||||||||||||
| curve: Curves.easeIn, | ||||||||||||||||||
| reverseCurve: Curves.easeOut, | ||||||||||||||||||
| ); | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| Code after migration: | ||||||||||||||||||
|
|
||||||||||||||||||
| ```dart | ||||||||||||||||||
| // This doesn't use `reverseCurve` so it stays as `CurvedAnimation`: | ||||||||||||||||||
| final oneCurve = CurvedAnimation( | ||||||||||||||||||
| parent: _animationController, | ||||||||||||||||||
| curve: Curves.easeIn, | ||||||||||||||||||
| ); | ||||||||||||||||||
|
|
||||||||||||||||||
| // This uses `reverseCurve` so migrate to `AsymmetricCurvedAnimation`: | ||||||||||||||||||
| final twoCurves = AsymmetricCurvedAnimation( | ||||||||||||||||||
| parent: _animationController, | ||||||||||||||||||
| curve: Curves.easeIn, | ||||||||||||||||||
| reverseCurve: Curves.easeOut, | ||||||||||||||||||
| ); | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Timeline | ||||||||||||||||||
|
|
||||||||||||||||||
| Landed in version: Not yet<br> | ||||||||||||||||||
| In stable release: Not yet | ||||||||||||||||||
|
|
||||||||||||||||||
| ## References | ||||||||||||||||||
|
|
||||||||||||||||||
| {% render "docs/main-api.md", site: site %} | ||||||||||||||||||
|
|
||||||||||||||||||
| API documentation: | ||||||||||||||||||
|
|
||||||||||||||||||
| * [`CurvedAnimation`][] | ||||||||||||||||||
| * [`AsymmetricCurvedAnimation`][] | ||||||||||||||||||
|
|
||||||||||||||||||
| Relevant issues: | ||||||||||||||||||
|
|
||||||||||||||||||
| * [Disambiguate CurvedAnimation and CurveTween][] | ||||||||||||||||||
| * [Docs should instruct user to dispose `CurvedAnimation`][] | ||||||||||||||||||
|
|
||||||||||||||||||
| Relevant PRs: | ||||||||||||||||||
|
|
||||||||||||||||||
| * [Deprecate `CurvedAnimation.reverseCurve` for `AsymmetricCurvedAnimation`][] | ||||||||||||||||||
|
|
||||||||||||||||||
| [`AsymmetricCurvedAnimation`]: {{site.main-api}}/flutter/animation/AsymmetricCurvedAnimation-class.html | ||||||||||||||||||
| [`CurvedAnimation`]: {{site.main-api}}/flutter/animation/CurvedAnimation-class.html | ||||||||||||||||||
| [`dispose`]: {{site.main-api}}/flutter/animation/AsymmetricCurvedAnimation/dispose.html | ||||||||||||||||||
| [`parent`]: {{site.main-api}}/flutter/animation/CurvedAnimation/parent.html | ||||||||||||||||||
| [`reverseCurve`]: {{site.main-api}}/flutter/animation/AsymmetricCurvedAnimation/reverseCurve.html | ||||||||||||||||||
|
Comment on lines
+106
to
+108
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the new reference link definitions for
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| [Disambiguate CurvedAnimation and CurveTween]: {{site.repo.flutter}}/issues/185468 | ||||||||||||||||||
| [Docs should instruct user to dispose `CurvedAnimation`]: {{site.repo.flutter}}/issues/183292 | ||||||||||||||||||
| [Deprecate `CurvedAnimation.reverseCurve` for `AsymmetricCurvedAnimation`]: {{site.repo.flutter}}/pull/185797 | ||||||||||||||||||
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.
The link
[reverseCurve][]currently points toAsymmetricCurvedAnimation/reverseCurve.html. Since this sentence refers to the deprecated field onCurvedAnimation, it should point toCurvedAnimation/reverseCurve.htmlinstead. We can define a specific reference link[CurvedAnimation.reverseCurve]at the bottom of the file and use it here.