[framework] Animatable.fromCallback and code snippet#108661
[framework] Animatable.fromCallback and code snippet#108661auto-submit[bot] merged 8 commits intoflutter:masterfrom
Conversation
|
@goderbauer I'd like to redeem my points :smile . I noticed another pattern I was unable to replace with the |
There was a problem hiding this comment.
Could use AnimationWithParentMixin?
There was a problem hiding this comment.
In theory, you can achieve the same thing by implementing a custom Animatable class (only have to implement the transform method with the closure you would provide here) and then use Animation.drive.
This API avoids the extra class definition, I guess. Is that really such a hassle?
There was a problem hiding this comment.
Oh, and I guess Animation.drive only works if the parent is a Animation<double>. This one in theory allows any Animation to be transformed into any other... Is that a feature you need?
There was a problem hiding this comment.
Ahh maybe, let me look into that more.
|
Drive solves this problem. Perhaps I should re-tool this PR into an additional of how to use Animation.drive? |
That would be much appreciated! |
8a79be9 to
c8ae27e
Compare
| /// | ||
| /// * [Animation.drive], which provides an example for how this can be | ||
| /// used. | ||
| const factory Animatable.fromCallback(AnimatableCallback<T> callback) = _CallbackAnimatable<T>; |
There was a problem hiding this comment.
Just a little bit more API. It felt a bit silly to create a class just to wrap a callback in the sample code
| /// * [CurvedAnimation], an alternative to [CurveTween] for applying easing | ||
| /// curves, which supports distinct curves in the forward direction and the | ||
| /// reverse direction. | ||
| /// * [Animatable.fromCallback], which allows creating an animatable from an |
There was a problem hiding this comment.
nit: animatable -> Animatable (or [Animatable])?
| /// })); | ||
| /// ``` | ||
| /// | ||
| /// {@end-tool} |
| // late Animation<Offset> _animation; | ||
| // late AnimationController _controller; | ||
|
|
||
| /// A typedef used to create an [Animatable] from a callback. |
There was a problem hiding this comment.
nit: As per style guide link this doc directly to its use by including [Animatable.fromCallback] in the doc comment.
Add an easy way to transform an animation using a callback