FlutterGen / flutter_gen

The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs.
https://pub.dev/packages/flutter_gen
MIT License
1.48k stars 150 forks source link

[FR]: dotLottie support #505

Open josh-burton opened 7 months ago

josh-burton commented 7 months ago

Is there an existing issue for this?

Describe the problem

dotLottie is compressed lottie file format that would be great to support

Describe the solution

Support the file format

Additional context

No response

Code of Conduct

AlexV525 commented 5 months ago

Could you provide the spec of the format and a use case that how Lottie in Flutter uses that format?

dungngminh commented 5 days ago

This is document of dotLottie from Lottie: https://lottiefiles.notion.site/Getting-started-with-dotLottie-907cb7b157b34990a7bba7bcae8f21b0

As mentioned in this document, dotLotties is allowing for considerably smaller animation files compared to JSON. It makes Lottie animation file size smaller than JSON and has some benefits in Lottie Development and Design.

lottie package currently supports dotLottie from 3.0.0, I think flutter_gen currently supports .zip and hopefully will support dotLotties ASAP.

AlexV525 commented 2 days ago

Looks like we can accept the .lottie extension as an easy approach.

EDIT: I was looking at the implementation of the package:lottie and it seems to require some extra definition which looks inaccessible by the library.

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');
  });
}

Consider the above code, the JSON file is manually picked by the iterator. We didn't support generating something like that so the generated assets probably won't have a .lottie constructor.

dungngminh commented 2 days ago

Make sense! If you can accept it as extension, I think we should add more docs / notes for require some extra definition attention

dungngminh commented 2 days ago

decoder basically is a parameter of Lottie, it need to be provided customDecoder for .lottie file is must do, developers must read documentation and know it before implementation.