Use case
Currently, it's ambiguous for a user whether to use CurvedAnimation or CurveTween. The new documentation in #184569 helps, but it's ultimately just a band-aid highlighting a confusing API.
I see the issue being that CurvedAnimation and CurveTween do exactly the same thing in the common case where CurvedAnimation.reverseCurve is not used. Therefore, we should discourage using CurvedAnimation without a reverseCurve in some intuitive way.
This proposal follows on from an unanswered question in #183292 (comment) (but slightly different).
Proposal
This has since been reworked: see the below comment
Here is the original proposal...
Rename CurvedAnimation to ReversibleCurvedAnimation, and make CurvedAnimation.reverseCurve a required argument:
- CurvedAnimation({required this.parent, required this.curve, this.reverseCurve}) {
+ ReversibleCurvedAnimation({required this.parent, required this.curve, required this.reverseCurve}) {
This is a breaking change, and users are advised to migrate in one of the following ways:
- If reverseCurve is not needed, use
CurveTween.
- If reverseCurve is needed and specified, replace with
ReversibleCurvedAnimation.
- If reverseCurve is needed but not specified at instantiation, replace with
ReversibleCurvedAnimation and explicitly specify reverseCurve as null.
I will make a pull request shortly. I'm currently adding data-driven fixes and updating all the examples.
Use case
Currently, it's ambiguous for a user whether to use
CurvedAnimationorCurveTween. The new documentation in #184569 helps, but it's ultimately just a band-aid highlighting a confusing API.I see the issue being that
CurvedAnimationandCurveTweendo exactly the same thing in the common case whereCurvedAnimation.reverseCurveis not used. Therefore, we should discourage usingCurvedAnimationwithout areverseCurvein some intuitive way.This proposal follows on from an unanswered question in #183292 (comment) (but slightly different).
Proposal
This has since been reworked: see the below comment
Here is the original proposal...
Rename
CurvedAnimationtoReversibleCurvedAnimation, and makeCurvedAnimation.reverseCurvea required argument:This is a breaking change, and users are advised to migrate in one of the following ways:
CurveTween.ReversibleCurvedAnimation.ReversibleCurvedAnimationand explicitly specifyreverseCurveas null.I will make a pull request shortly. I'm currently adding data-driven fixes and updating all the examples.