Orientação gerada a partir de informações públicas. Apenas para referência.
Lottie é um pacote do Flutter que permite o renderização nativa de animações criadas no Adobe After Effects usando o formato Lottie. Construído inteiramente em Dart, oferece reprodução suave em múltiplas plataformas sem exigir código nativo. O pacote suporta animações baseadas em vetores, tornando-as leves e escaláveis. É ideal para integrar animações dinâmicas e de alta qualidade em aplicativos com pouco custo operacional. O Lottie simplifica o processo de trazer gráficos animados envolventes para aplicativos Flutter.
Casos de uso
Indicadores de carregamento
Telas de onboarding
Elementos de interface interativos
Micro-interactions
Telas de inicialização do app
Principais recursos
Implementação pura em Dart
Suporte multiplataforma
Renderização de animação de alto desempenho
Suporte para arquivos Lottie baseados em JSON
Integração fácil com widgets do Flutter
Indicado para
Desenvolvedores em busca de animações leves
Aplicativos que exigem feedback visual rico
Designers colaborando com desenvolvedores
Projetos direcionados para múltiplas plataformas
Considerações
Arquivos Lottie grandes podem afetar o desempenho
Animações complexas podem exigir otimização
Controle limitado sobre camadas individuais de animação
Não adequado para animações altamente personalizadas ou complexas
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
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.