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.44k stars 142 forks source link

Feature Request: Lottie files #47

Closed vintage closed 4 months ago

vintage commented 3 years ago

Hey there!

Would be great to have integration for the lottie files (through https://pub.dev/packages/lottie). Right now in the project I'm working on we're using the syntax:

Lottie.asset(Assets.animations.animationName)

but would be lovely to achieve it just like for the SVG files through the generated code:

Assets.animations.animationName.lottie()

The trickiest part would be probably to distinguish lottie files from non-lottie files, as it uses .json as the file extension?

jamesblasco commented 2 years ago

@wasabeef would you be interested in a PR for this?. I am using flutter_gen in a project and I would like to generate lottie assets with it.

I think the implementation is almost straight forward, the only thing is the file extension .json is very vague. I was thinking to only support files with the name *_lottie.json. What do you think about it?

nguyenvinhtien28 commented 2 years ago

@wasabeef would you be interested in a PR for this?. I am using flutter_gen in a project and I would like to generate lottie assets with it.

I think the implementation is almost straight forward, the only thing is the file extension .json is very vague. I was thinking to only support files with the name *_lottie.json. What do you think about it?

I think it's a good idea. Please implement it.

bramp commented 8 months ago

This issue has been fixed ~a year ago.

As for https://github.com/FlutterGen/flutter_gen/issues/47#issuecomment-966241081 the implementation finds all .json files that contain a json object with specific keys and a version of > 4.4.0. This can still lead to false positives, but seems rare.