Render After Effects animations natively on Flutter. This package is a pure Dart implementation of a Lottie player.
MIT License
Bot releases are hidden (Show)
Published by xvrh 9 months ago
Add support for layer blend mode
Allow to load Telegram Stickers (.tgs)
Lottie.asset(
'sticker.tgs',
decoder: LottieComposition.decodeGZip,
)
renderCache
parameter.Lottie.asset('assets/complex_animation.json',
renderCache: RenderCache.raster,
)
Opt-in to a special render mode where the frames of the animation are lazily rendered and kept in a cache.
Subsequent runs of the animation are cheaper to render.
There are 2 kinds of caches:
RenderCache.raster: keep the frame rasterized in the cache (as [dart:ui.Image]).
Subsequent runs of the animation are very cheap for both the CPU and GPU but it takes
a lot of memory.
RenderCache.drawingCommands: keep the frame as a list of graphical operations ([dart:ui.Picture]).
Subsequent runs of the animation are cheaper for the CPU but not for the GPU.
Lottie.asset(
'animation.lottie',
decoder: customDecoder,
);
Future<LottieComposition?> customDecoder(List<int> bytes) {
return LottieComposition.decodeZip(bytes, filePicker: (files) {
return files.firstWhere((f) => f.name == 'animations/cat.json');
});
}
Add backgroundLoading
parameter to Lottie.asset|network|file|memory
.
If backgroundLoading
is true, the animation will be loaded in a background isolate.
This is useful for large animations that can take a long time to parse and block the UI work.
Remove the name property from LottieComposition
imageProviderFactory
is not used in .zip file by default anymore.
To restore the old behaviour, use:
Future<LottieComposition?> decoder(List<int> bytes) {
return LottieComposition.decodeZip(bytes, imageProviderFactory: imageProviderFactory);
}
Lottie.asset('anim.json', decoder: decoder)
ValueDelegate.gradientColor
is usedDefaultAssetBundle.of
in AssetLottie
before fallback to rootBundle
BuildContext
optional parameter in LottieProvider.load
Published by xvrh 10 months ago
Add backgroundLoading
parameter to Lottie.asset|network|file|memory
.
If backgroundLoading
is true, the animation will be loaded in a background isolate.
This is useful for large animations that can take a long time to parse and block the UI work.
Replace enableRenderCache
with renderCache: RenderCache.raster
.
The new class RenderCache
allows to specify the cache behaviour:
RenderCache.raster
: Cache the frames as rasterized images living in the GPU memory.RenderCache.drawingCommands
: Cache the frames as a list of graphical operations. This will only save CPUPublished by xvrh 11 months ago
enableRenderCache
(now limited to 50MB)Lottie.renderCacheMaxMemory = 75000000;
Published by xvrh 11 months ago
Published by xvrh 11 months ago
enableRenderCache
parameter.Lottie.asset('assets/complex_animation.json',
enableRenderCache: true,
)
It allows to opt into a mode where the frames of the animation are rendered lazily in an offscreen cache.
Subsequent runs of the animation will be very cheap to render.
This is useful is the animation is complex and can consume a lot of energy from the battery.
It's a trade-off to lower the CPU usage at the cost of an increased memory usage.
The render cache is managed internally and will release the memory once the animation is disposed.
The cache is shared between all animations. If 2 Lottie
widget are rendered at the same size, they will render only
once.
Any change in the configuration of the animation (delegates, frame rate etc...) will clear the cache.
Any change in the size will invalidate the cache. The cache use the final size visible on the screen (with all
transforms applied).
Lottie.asset(
'sticker.tgs',
decoder: LottieComposition.decodeGZip,
)
Lottie.asset(
'animation.lottie',
decoder: customDecoder,
);
Future<LottieComposition?> customDecoder(List<int> bytes) {
return LottieComposition.decodeZip(bytes, filePicker: (files) {
return files.firstWhere((f) => f.name == 'animations/cat.json');
});
}
LottieComposition
imageProviderFactory
is not used in .zip file by default anymore.Future<LottieComposition?> decoder(List<int> bytes) {
return LottieComposition.decodeZip(bytes, imageProviderFactory: imageProviderFactory);
}
Lottie.asset('anim.json', imageProviderFactory: imageProviderFactory, decoder: decoder)
ValueDelegate.gradientColor
is usedDefaultAssetBundle.of
in AssetLottie
before fallback to rootBundle
BuildContext
optional parameter in LottieProvider.load
Published by xvrh almost 1 year ago
Published by xvrh about 1 year ago
List<int>
instead of Uint8List
in LottieComposition.fromBytesPublished by xvrh over 1 year ago
Published by xvrh over 1 year ago
Published by xvrh over 1 year ago
Published by xvrh over 1 year ago
Published by xvrh over 1 year ago
Published by xvrh almost 2 years ago
Apply the latest fixes from Lottie-Android:
Published by xvrh almost 2 years ago
AssetLottie('anim.json').load()
returns a SynchronousFuture
if it has been loaded previously.LottieCache
singleton.void main() {
Lottie.cache.maximumSize = 10;
Lottie.cache.clear();
Lottie.cache.evict(NetworkLottie('https://lottie.com/anim.json'));
}
Published by xvrh almost 2 years ago
Breaking change: the lottie widget will be smaller if it relies on the intrinsic size of the composition.
Previously the lottie parser was automatically multiplying the size of the composition by window.devicePixelRatio. This was incorrect as it results in a widget of a different size depending on the pixel ratio of the monitor. Furthermore, it created some bugs when the property window.devicePixelRatio was not available immediately at the start of the app (on Android release builds).
The code can be adapted to specify explicitly the size of the animation with width, height and fit properties.
Scaffold(
body: Center(
child: Lottie.asset(
'assets/LottieLogo1.json',
height: 800,
fit: BoxFit.contain,
),
),
);
Published by xvrh about 2 years ago
Published by xvrh about 2 years ago
FilterQuality.low
as default to draw image layers.Published by xvrh about 2 years ago
AlignmentGeometry
for alignment
.Published by xvrh about 2 years ago
filterQuality
property to control the performance vs quality trade-off to use when drawing images