Closed tinyjin closed 7 months ago
I totally agree the features should be fully supported. This PR is for simply using dotlottie so I will check more about dotlottie spec and implement it If I can.
Thanks for review and comment. Talk to you soon!
@tinyjin the next version (currently v3.0.0-alpha.1), will expose a hook to customise how to decode zip archives. So you can choose the .json file from the archive like that:
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');
});
}
Please, give it a try and let me know if it works for you.
@xvrh Thank you for sharing, yup it worked.
It seems to bring user to easily select specific json from dotlottie and zip. Cool = )
@xvrh FYI. I checked dotlottie-loader which you mentioned and lists of full features on dotlottie.
Basically, dotlottie supports 3 new features
And as far as I found, dotlottie-loader supports this
Like this, In loader callback, we can drive multi animation, we can modify animations.values.single
, images[asset.fileName]
DotLottieLoader.fromAsset("assets/animation_inline_image.lottie",
frameBuilder: (ctx, dotlottie) {
if (dotlottie != null) {
return Lottie.memory(dotlottie.animations.values.single,
imageProviderFactory: (asset) {
return MemoryImage(dotlottie.images[asset.fileName]!);
}
);
} else {
return Container();
}
}),
But not so sure It's enough interface for developer, because we have to install two different library and write messed code to load dotlottie into flutter app.
What I'm thinking for ideal code is just like this.
Lottie.asset(
'assets/cat.lottie',
activeAnimationId: 'cat_animation'
),
It's similar with web dotlottie-player (link)
The dotlottie-loader and your new interface which you just requested me to review are also cool and amazing. Am still thinking more comfortable code base to integrate dotlottie with your lib so user just like me can load dotlottie and use multianimation with even little bit of code lines.
SO I'm going to prepare this support and request PR again however WHAT DO YOU THINK?
hello, closed issue as there's no activity =)
Hi, there, Thanks for this library. However, there wasn't any support to use dotlottie. So I just added simple code to implement it.
I know this lib is already supporting zip format which is same size with dotlottie. But I thought It's still needed dotlottie compatible because dotlottie is more familiar than zip for lottie user.
Also, it could be improved as an independent binary so It'd be better to have dotlottie composition for then!
issue: #295
People don't have to reformat dotlottie into zip from now on. I already tested it with some example written by dotlottie and it worked well.