Skip to main content
Lottie to codeUpdated November 20265 min read

Lottie to Flutter: playing a Lottie file in Flutter

The short answer

The usual route is the lottie package: add the JSON to your assets and render a Lottie.asset widget. The alternative is to convert the animation into an .exode file and render it with exodeui_flutter, which keeps states, inputs and physics in the file instead of in Dart widgets around it.

What matters

  • Flutter has a well-maintained lottie package and it is the shortest path for decorative motion.
  • Lottie animation is playback: the widget controls play, pause and repeat, not logic.
  • ExodeUI renders .exode files on a canvas, so one file behaves the same on iOS and Android.
  • Bones, IK and constraints carry over from a Rive file too, if you are coming from there.
  • The runtime is free to use. ExodeUI Community costs nothing; Professional is $5 per month billed yearly.

Playing a Lottie file in Flutter today

The standard approach is a player component that takes the exported JSON and renders it. It is small, it works, and if the animation is a decorative loader or a success tick, it is the right answer.

What it cannot do is change behaviour. If the design calls for the animation to react — pause on hover, spring back when dragged, switch to an error state when a request fails — that logic has to be written in your component around the player, and the animation itself stays fixed.

The import route

The other option is to move the animation into ExodeUI, where the timeline, the inputs and the logic live in one file. Drop your Lottie JSON on /import/lottie, check how it converts, then add states and physics to it on the canvas instead of in code.

Add the .exode file to your pubspec.yaml assets list. The runtime reads the JSON as a string, so no platform channels and no native build step.

We make ExodeUI, so treat that suggestion as the vendor recommending its own runtime. If the animation is a fixed performance with nothing to interact with, a Lottie player is the simpler answer.

The Flutter code

Load the .exode JSON from assets with rootBundle, then hand it to the canvas. A GlobalKey gives you the controller for inputs at runtime.

$flutter pub add exodeui_flutter
Flutter
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:exodeui_flutter/exodeui_flutter.dart';

// Add assets/loader.exode to pubspec.yaml
class Loader extends StatefulWidget {
  const Loader({super.key});
  @override
  State<Loader> createState() => _LoaderState();
}

class _LoaderState extends State<Loader> {
  final _canvas = GlobalKey<ExodeUICanvasState>();
  late final Future<String> _json = rootBundle.loadString('assets/loader.exode');

  @override
  Widget build(BuildContext context) {
    return FutureBuilder<String>(
      future: _json,
      builder: (context, snap) => snap.hasData
          ? ExodeUICanvas(
              key: _canvas,
              artboardJson: snap.data!,
              fit: 'Layout',
              onReady: () {
                _canvas.currentState?.setInputNumber('progress', 0.4);
              },
            )
          : const SizedBox.shrink(),
    );
  }
}

Inputs go in, events come out. The component you ship is a canvas that renders the file, not a pile of keyframes translated into framework code, so a designer can retune the spring without touching the component.

Which route to pick

Use the plain player when the animation is a one-way performance: a loading state, an empty-state illustration, a marketing flourish. There is nothing to interact with, so a timeline is the whole job.

Use the runtime when the thing on screen is a component people operate. A toggle, a drag-to-dismiss card, a form field with focus, loading, error and success states — those are not animations that play, they are motion bound to state, and putting the motion in the file keeps the component short.

Questions

How do I add a Lottie animation in Flutter?

Add the lottie package, put the JSON file in your assets folder, declare it in pubspec.yaml, and render Lottie.asset with the asset path. For remote files use Lottie.network, which caches after the first load.

Do I need a LottieFiles subscription to play a Lottie file?

No. Lottie is an open JSON format and the players that render it are open source. A LottieFiles subscription buys the asset library, hosting and team workflow, not permission to render the format.

Can a Lottie file hold state or logic?

A Lottie file is a timeline. Interactivity comes from the player API — you call play, pause or go to a frame from your code — so the states live in your component, not in the file.

Does the Lottie import upload my file?

No. The conversion runs in your browser and the file stays on your device. Only a usage count is recorded.

Can Flutter play interactive animations with state?

Flutter widgets can drive playback, but states and transitions written in widget code tend to spread across the tree. With the ExodeUI Flutter runtime the states, inputs and physics live in the .exode file, and the widget passes inputs in and receives events.

Related

Open the editor and try it on your own file

Free Community plan. No credit card. One open .exode file runs in React, Vue, Flutter and more.

Open the web editor
ExodeUI

EXODEUI DESKTOP

A little space for good ideas.

Choose your platform to get the official ExodeUI installer.

Looking for Intel Mac or other builds? Explore the web studio or check all download options.

Prefer the browser? Try for free in your browser →