AnimatedGradient constructor
- Key? key,
- required Animation<
double> controller, - required Gradient gradient,
- Map<
GradientAnimation, dynamic> storyboard = const {}, - GradientCopyWith overrideCopyWith = spectrumCopyWith,
Use this object's observe property, after providing some controller
,
to drive a customizable animation on the gradientInput by tweaking
the storyboard map of GradientAnimations.
Provide, for example, an AnimationController as controller
to push the
flow of the animation. Consider driving the controller by
controller.repeat(reverse:true)
.
Not intended to have build called like a true Widget
.
Instead opt to observe the Gradient-type output.
- If this
Widget
is treed out and built, however, the return is a DecoratedBox whose gradient is set to observe.
Animated Gradient Storyboard Map
A "Gradient Storyboard" value provided as storyboard maps GradientAnimations to relevant values to apply those animation transformations.
Beyond ColorArithmetic & StopsArithmetic animation transformations, GradientAnimation.tweenSpec may be mapped to a "TweenSpec" to detail individual Tweens for each of the many potential Gradient sub-type properties (such as LinearGradient.begin or RadialGradient.radius).
This "TweenSpec" is a Map<GradientProperty, Tween<dynamic>>
.
GradientAnimation
Mappings
If GradientAnimation.colorArithmetic
is mapped to a ColorArithmetic,
then that function applies Gradient.colors animation transformations.
See Shades for more ideas.
If GradientAnimation.stopsArithmetic
is mapped to a StopsArithmetic,
then that function applies Gradient.stops animation transformations.
See Maths for more ideas.
If GradientAnimation.tweenSpec
is mapped to a "TweenSpec", then that
object allows the mapping of Tweens to any potential GradientProperty.
Custom copyWith()
Function
In order to utilize custom, bespoke Gradient types that would not be
hard-code recognized by this package and its default copyWith()
method,
provide a GradientCopyWith override for _copyWith
.
Implementation
// [GradientAnimation.tweenSpec] may be mapped to a [TweenSpec] to detail
/// [GradientAnimation.tweenSpec] may be mapped to a "TweenSpec" to detail
/// individual [Tween]s for each of the many potential [Gradient] sub-type
/// properties (such as [LinearGradient.begin] or [RadialGradient.radius]).
///
/// This "TweenSpec" is a `Map<GradientProperty, Tween<dynamic>>`.
///
/// ## `GradientAnimation` Mappings
/// If `GradientAnimation.colorArithmetic` is mapped to a [ColorArithmetic],
/// then that function applies [Gradient.colors] animation transformations. \
/// See [Shades] for more ideas.
///
/// If `GradientAnimation.stopsArithmetic` is mapped to a [StopsArithmetic],
/// then that function applies [Gradient.stops] animation transformations. \
/// See [Maths] for more ideas.
///
// If `GradientAnimation.tweenSpec` is mapped to a [TweenSpec], then *that*
/// If `GradientAnimation.tweenSpec` is mapped to a "TweenSpec", then *that*
/// object allows the mapping of [Tween]s to any potential [GradientProperty].
///
/// ## Custom `copyWith()` Function
/// In order to utilize custom, bespoke [Gradient] types that would not be
/// hard-code recognized by this package and its default `copyWith()` method,
/// provide a [GradientCopyWith] override for [_copyWith].
const AnimatedGradient({
Key? key,
required Animation<double> controller,
required Gradient gradient,
this.storyboard = const {},
GradientCopyWith overrideCopyWith = spectrumCopyWith,
}) : _copyWith = overrideCopyWith,
_gradient = gradient,
super(key: key, listenable: controller);