flame

Adds support for Lottie animations to your Flame games.


flame_lottie

This package allows you to load and add Lottie animations to your Flame game.

Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations exported as json with Bodymovin and renders them natively on mobile!

Source: lottie-android on Github

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 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:

... 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(
            composition: animation,
            repeating: true, // continuously loop the animation
        ),
    );
  }
  ...
}

Libraries

flame_lottie