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