flame_lottie¶
This package allows you to load and add Lottie animations to your Flame game.
The native Lottie libraries (such as lottie-android) are maintained by Airbnb.
The Flutter package lottie
, on which this wrapper is based on, is by developed xaha.dev and
can be found on pub.dev.
Usage¶
To use it in your game you just need to add flame_lottie
to your pubspec.yaml.
Simply load the Lottie animation using the loadLottie method and the LottieBuilder. It allows all the various ways of loading a Lottie file:
Lottie.asset, for obtaining a Lottie file from an AssetBundle using a key.
Lottie.network, for obtaining a lottie file from a URL.
Lottie.file, for obtaining a lottie file from a File.
Lottie.memory, for obtaining a lottie file from a Uint8List.
… and add it as LottieComponent
to your Flame 🔥 game.
Example:
class MyGame extends FlameGame {
...
@override
Future<void> onLoad() async {
final asset = Lottie.asset('assets/LottieLogo1.json');
final animation = await loadLottie(asset);
add(
LottieComponent(
animation,
repeating: true, // Continuously loop the animation.
size: Vector2.all(400),
),
);
}
...
}