Lottie는 Adobe After Effects에서 생성한 Lottie 형식의 애니메이션을 네이티브 렌더링할 수 있도록 해주는 Flutter 패키지입니다. Dart로 완전히 구현되어 있으며, 네이티브 코드 없이 여러 플랫폼에서 부드러운 재생을 제공합니다. 벡터 기반 애니메이션을 지원하여 가볍고 확장 가능한 애니메이션을 만들 수 있습니다. 최소한의 오버헤드로 앱에 동적이고 고품질의 애니메이션을 통합하는 데 이상적입니다. Lottie는 Flutter 애플리케이션에 매력적인 모션 그래픽을 쉽게 도입할 수 있도록 합니다.
사용 사례
로딩 표시기
온보딩 화면
인터랙티브 UI 요소
Micro-interactions
앱 스플래시 화면
주요 기능
순수 Dart 구현
크로스 플랫폼 지원
고성능 애니메이션 렌더링
JSON 기반 Lottie 파일 지원
Flutter 위젯과의 간편한 통합
적합한 대상
경량 애니메이션을 찾는 개발자
풍부한 시각적 피드백이 필요한 앱
디자이너와 개발자들이 협력하는 방식
다중 플랫폼을 대상으로 하는 프로젝트
고려 사항
큰 Lottie 파일은 성능에 영향을 줄 수 있습니다
복잡한 애니메이션은 최적화가 필요할 수 있습니다
개별 애니메이션 레이어에 대한 제어가 제한됨
매우 맞춤형이거나 복잡한 애니메이션에는 적합하지 않습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Lottie for Flutter
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!
This repository is an unofficial conversion of the Lottie-android library in pure Dart.
It works on Android, iOS, macOS, linux, windows and web.
Usage
Simple animation
This example shows how to display a Lottie animation in the simplest way.
The Lottie widget will load the json file and run the animation indefinitely.
import'package:flutter/material.dart';
import'package:lottie/lottie.dart';
voidmain() => runApp(constMyApp());
classMyAppextendsStatelessWidget{
constMyApp({super.key});
@overrideWidgetbuild(BuildContext context) {
returnMaterialApp(
home: Scaffold(
body: ListView(
children: [
// Load a Lottie file from your assetsLottie.asset('assets/LottieLogo1.json'),
// Load a Lottie file from a remote urlLottie.network(
'https://raw.githubusercontent.com/xvrh/lottie-flutter/master/example/assets/Mobilo/A.json',
),
// Load an animation and its images from a zip fileLottie.asset('assets/lottiefiles/angel.zip'),
],
),
),
);
}
}
Specify a custom AnimationController
This example shows how to take full control over the animation by providing your own AnimationController.
With a custom AnimationController you have a rich API to play the animation in various ways: start and stop the animation when you want,
play forward or backward, loop between specifics points...
width and height are optionals and fallback on the size imposed by the parent or on the intrinsic size of the lottie
animation.
Custom loading
The Lottie widget has several convenient constructors (Lottie.asset, Lottie.network, Lottie.memory) to load, parse and
cache automatically the json file.
Sometime you may prefer to have full control over the loading of the file. Use AssetLottie (or NetworkLottie, MemoryLottie) to load a lottie composition from a json file.
This example shows how to load and parse a Lottie composition from a json file.
This example shows how to modify some properties of the animation at runtime. Here we change the text,
the color, the opacity and the position of some layers.
For each ValueDelegate we can either provide a static value or a callback to compute a value for a each frame.
By default, the animation is played at the frame rate exported by AfterEffect.
This is the most power-friendly as generally the animation is exported at 10 or 30 FPS compared to the phone's 60 or 120 FPS.
If the result is not good, you can change the frame rate
Lottie.asset('anim.json',
// Use the device frame rate (up to 120FPS)
frameRate: FrameRate.max,
// Use the exported frame rate (default)
frameRate: FrameRate.composition,
// Specific frame rate
frameRate: FrameRate(10),
)
Telegram Stickers (.tgs) and DotLottie (.lottie)
TGS file can be loaded by providing a special decoder
Version v3.0 introduced the renderCache parameter to help reduce an excessive energy consumption.
In this mode, the frames of the animation are rendered lazily in an offscreen cache. Subsequent runs of the animation
are cheaper to render. It helps reduce the power usage of the application at the cost of an increased memory usage.