-
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
Draft
adil192
wants to merge
4
commits into
flutter:main
Choose a base branch
from
adil192:breaking-changes/deprecate-curved-animation-reverse-curve
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+118
−0
Draft
*Breaking change* Deprecate CurvedAnimation.reverseCurve in favor of AsymmetricCurvedAnimation
#13347
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f17a81a
*Breaking change* Deprecate `CurvedAnimation.reverseCurve` in favor o…
adil192 ad165a8
Update sites/docs/src/content/release/breaking-changes/deprecate-curv…
sfshaza2 e163991
Merge branch 'main' into breaking-changes/deprecate-curved-animation-…
parlough 2321bc7
Minor clean up and formatting adjustments
parlough File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
126 changes: 126 additions & 0 deletions
126
...rc/content/release/breaking-changes/deprecate-curved-animation-reverse-curve.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| --- | ||
| 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. | ||
|
|
||
| If needed, | ||
| switch from [`CurvedAnimation`][] to [`AsymmetricCurvedAnimation`][]. | ||
|
|
||
| ## Background | ||
|
|
||
| To support its [`reverseCurve`][] functionality, | ||
| `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 stick around in memory and prevent Dart from freeing up | ||
| unneeded resources. | ||
|
|
||
| But the most common use case of `CurvedAnimation` is with a single curve, | ||
| meaning these listeners aren't even needed most of the time. | ||
|
|
||
| For this reason, [`reverseCurve`][] is being removed from [`CurvedAnimation`][] | ||
| and moved to [`AsymmetricCurvedAnimation`][]. | ||
|
|
||
| After a migration period, it will be removed from `CurvedAnimation` alongside | ||
| its listeners. This means more memory safety with [`CurvedAnimation`][] | ||
| and less code to write, since you won't need to dispose it. | ||
|
|
||
| (Until the migration period is over, remember to still call [`dispose`] when | ||
| you're done. | ||
| If you use [`AsymmetricCurvedAnimation`][], you still need to call its | ||
| [`dispose`][] method regardless.) | ||
|
|
||
| ## Migration guide | ||
|
|
||
| If you need [`CurvedAnimation`][]'s [`reverseCurve`][] field, | ||
| 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 | ||
|
|
||
| {% comment %} | ||
| The version # of the SDK where this change was | ||
| introduced. If there is a deprecation window, | ||
| the version # to which we guarantee to maintain | ||
| the old API. Use the following template: | ||
|
|
||
| If a breaking change has been reverted in a | ||
| subsequent release, move that item to the | ||
| "Reverted" section of the index.md file. | ||
| Also add the "Reverted in version" line, | ||
| shown as optional below. Otherwise, delete | ||
| that line. | ||
| {% endcomment %} | ||
|
|
||
| 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 | ||
|
|
||
| [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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.