CustomAnimation<T> class
Widget that creates a customized animation.
You need to specify a tween that describes your animation and builder function that is called each frame you are animating. This function has signature of AnimatedWidgetBuilder.
It's also useful to specify a duration (default is 1 second).
You can modify the internal AnimationController
by setting the
control property to any value of [CustomAnimationControl).
By default it starts playing the animation.
Nice to know: both duration and control can be modified at any time while using it inside a stateful widget.
To improve the performance of your animation you should put all widgets that are not effected by the animation into the child property. You get that child widget passed into the builder function. See also AnimatedWidgetBuilder.
If you specify a delay the animation will wait for the given duration until it will started animating.
The curve parameter can be used to apply a non-linear animation to your tween.
If you want to start your animation at alternative position, you
can set a startPosition that takes values between 0.0
(start)
and 1.0
(end).
You can optionally limit the framerate (fps) of the animation by setting the fps value.
You can provide an animationStatusListener that gets called by
the internal AnimationController
. It's receives events of the
type AnimationStatus.
If you work with multiple animation widgets that are conditionally rendered, you might want to set a key. Otherwise Flutter will recycled your "old animation" which results in strange behavior.
You can connect this widget to the closest AnimationDeveloperTools
by setting developerMode to true
.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- CustomAnimation
Constructors
-
CustomAnimation({required AnimatedWidgetBuilder<
T> builder, required Animatable<T> tween, CustomAnimationControl control = CustomAnimationControl.play, Curve curve = Curves.linear, Duration duration = const Duration(seconds: 1), Duration delay = Duration.zero, double startPosition = 0.0, Widget? child, AnimationStatusListener? animationStatusListener, int? fps, bool developerMode = false, Key? key}) -
Creates a new CustomAnimation widget.
See class documentation for more information.
const
Properties
- animationStatusListener → AnimationStatusListener?
-
final
-
builder
→ AnimatedWidgetBuilder<
T> -
final
- child → Widget?
-
final
- control → CustomAnimationControl
-
final
- curve → Curve
-
final
- delay → Duration
-
final
- developerMode → bool
-
final
- duration → Duration
-
final
- fps → int?
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- startPosition → double
-
final
-
tween
→ Animatable<
T> -
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _CustomAnimationState< T> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited