dartnative_lottie
Play Lottie animations natively in DartNative — from a bundled asset, runtime JSON, or a URL — driven by Airbnb's Lottie engine. iOS and Android.
Why you'll like it
- The real Lottie engine —
lottie-iosandlottie-android, so animations play through Core Animation / the Android view system (smooth, hardware-friendly). - Three sources — bundled asset, runtime JSON string, or a remote URL (with caching).
- Play it your way — autoplay + loop, or drive it imperatively with a
LottieController.
Highlights
Lottie(asset: …)/Lottie(json: …)/Lottie(url: …)— the animation widget.loop,autoplay,speed,fit(LottieFit), andcachePolicy(LottieCachePolicy.disk/.none) inline.LottieController—play()/pause()/stop()/setProgress(0..1)/setLoopMode(LottieLoopMode…), plus aprogressValueNotifier.LottieCache.preload([urls])— warm.json/.zip/.lottieURLs ahead of time; watchLottieCache.progressStream.
Install
dependencies:
dartnative_lottie: ^1.0.0 # from dartpub.dev
dn pub get
void main() {
DartNativePluginRegistrant.registerAll();
runApp(const MyApp());
}
Quick look
import 'package:dartnative_lottie/dartnative_lottie.dart';
Play a bundled animation on a loop:
Lottie(asset: 'assets/loading.json', loop: true);
From JSON fetched at runtime, a bit faster:
Lottie(json: jsonString, autoplay: true, speed: 1.5);
Drive it imperatively:
final controller = LottieController();
Lottie(asset: 'assets/check.json', autoplay: false, controller: controller);
// later…
controller.play();
controller.setProgress(0.5);
Platform setup
Assets and runtime JSON need no setup. Lottie(url: …) (and LottieCache.preload) fetch over the network:
iOS
Nothing for HTTPS. For an HTTP URL, add an App Transport Security exception in Info.plist.
Android
Requires minSdk 26 — set it in android/app/build.gradle.kts:
android { defaultConfig { minSdk = 26 } }
Add the internet permission to your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
Example
The example/ app plays animations from each source and drives one with a
controller — borrow from it freely.
Credits & license
Powered by Airbnb's Lottie —
lottie-ios and
lottie-android (Apache-2.0).
Commercial plugin distributed via dartpub.dev — file issues on the plugin's page.