PrismLottie class
Parses a Lottie JSON file and reports the metadata needed to size and play it.
Lottie animations are JSON files that describe vector shapes and keyframes. This class reads the file, extracts the frame rate, duration, dimensions and layer count, and reports whether the animation loops.
Prism deliberately does not include a Lottie renderer. Drawing Lottie
compositions requires a physics engine, a text renderer, and a gradient and
mask implementation — a large dependency for a component library. Instead,
use lottie or flutter_lottie for rendering, and this class for
everything else: preload, size calculation, and knowing when an animation
has finished.
final animation = await PrismLottie.fromAsset('animations/empty.json');
print('${animation.width} x ${animation.height}');
print('duration: ${animation.duration}');
Constructors
- PrismLottie({required double width, required double height, required double frameRate, required int frameCount, required bool loop, required int layers, required String version})
-
Creates a Lottie animation from parsed JSON.
const
- PrismLottie.fromJson(String json)
-
Parses a Lottie JSON string.
factory
Properties
- aspectRatio → double
-
Aspect ratio, which is useful for sizing a box around the animation.
no setter
- duration → Duration
-
Duration of one full playthrough.
no setter
- frameCount → int
-
Total number of frames in the animation.
final
- frameRate → double
-
Frame rate in frames per second.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double
-
Animation height in logical pixels.
final
- layers → int
-
Number of layers in the composition.
final
- loop → bool
-
Whether the animation loops.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- version → String
-
Lottie schema version the file was exported with.
final
- width → double
-
Animation width in logical pixels.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
fromAsset(
String path) → Future< PrismLottie> - Loads a Lottie animation from an asset path.