AnimatedVectorData class
Data for an animated vector, to use with widgets like AnimatedVector or inside a SequenceItem for AnimatedSequence.
It requires a root vector element that can apply a global alpha to the vector, and then as children PathElement, GroupElement and ClipPathElement can be used.
The duration parameter is used to define the target length of this animation, using an AnimationController with its duration set to it will make sure the vector runs at its intended speed.
viewportSize defines the size of the canvas for this vector animation, AnimatedVector.size allows you to modify the destination size to scale up or down.
The static methods loadFromFile and loadFromAsset allow users to load a Shape Shifter json vector animation dynamically at runtime. Where possible prefer to use code generation from animated_vector_gen as it's syncronous and allows for const instances to be created.
It is advised to always construct this class as const
as parameters that need
to be changed at runtime (like color) can be modified using utilities in the
widgets themselves.
- Available Extensions
Constructors
- AnimatedVectorData({required RootVectorElement root, required Duration duration, required Size viewportSize})
-
Constructs a new AnimatedVectorData instance.
const
Properties
- duration → Duration
-
The target duration of this vector data.
This value is propagated to elements and animation properties for normalization
purposes, it is advised to have this value big enough to contain every
animation interval inside the sequences.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- root → RootVectorElement
-
The root element of this vector data.
Mostly used to have a central entry point for painting elements, allows
to specify a global alpha value that can optionally be animated.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- viewportSize → Size
-
The viewport size which contains the elements.
Think of it as the size of the sheet of paper where you draw.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
paint(
Canvas canvas, Size size, double progress, Duration animationDuration, Matrix4 transform) → void - Paint this vector data onto a Canvas. The first two parameters behave the exact same way as CustomPainter.paint.
-
toJson(
String name) → Map< String, dynamic> - Converts this data into json content that can be opened and edited within Shape Shifter
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Methods
-
loadFromAsset(
String assetName, {AssetBundle? bundle, String? package}) → Future< AnimatedVectorData> -
Dynamically load an
AnimatedVectorData
from a json Shape Shifter file bundled in the app or other packages assets. Thepackage
parameter allows to specify a specific package to obtain the asset from. -
loadFromFile(
String path) → Future< AnimatedVectorData> -
Dynamically load an
AnimatedVectorData
from a json Shape Shifter file inside the file system.