Lottie
Render rich Lottie animations inside your Flet apps with a simple control.
It is backed by the lottie Flutter package.
Platform Support
| Platform | Windows | macOS | Linux | iOS | Android | Web |
|---|---|---|---|---|---|---|
| Supported | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Usage
Add the flet-lottie package to your project dependencies:
- uv
- pip
uv add flet-lottie
pip install flet-lottie
Example
Lottie animations
play_arrowTry Online
import flet as ft
import flet_lottie as ftl
def main(page: ft.Page):
page.add(
ft.SafeArea(
content=ft.Column(
controls=[
ftl.Lottie(
src="https://raw.githubusercontent.com/xvrh/lottie-flutter/master/example/assets/Mobilo/A.json",
reverse=False,
animate=True,
error_content=ft.Placeholder(ft.Text("Error loading Lottie")),
on_error=lambda e: print(f"Error loading Lottie: {e.data}"),
),
ftl.Lottie(
src="sample.json",
reverse=False,
animate=True,
enable_merge_paths=True,
enable_layers_opacity=True,
error_content=ft.Placeholder(ft.Text("Error loading Lottie")),
on_error=lambda e: print(f"Error loading Lottie: {e.data}"),
),
],
),
)
)
if __name__ == "__main__":
ft.run(main)
Description
Displays lottie animations.
Note
- Layer effects are currently not supported. See airbnb/lottie-android#1964 and xvrh/lottie-flutter#189 for details.
Inherits: LayoutControl
Properties
animate- Whether the animation should be played automatically.background_loading- Whether the animation should be loaded in the background.enable_layers_opacity- Whether to enable layer-level opacity.enable_merge_paths- Whether to enable merge path support.error_content- A control to display when an error occurs while loading the Lottie animation.filter_quality- The quality of the image layer.fit- Defines how to inscribe the Lottie composition into the space allocated during layout.headers- Headers for network requests.repeat- Whether the animation should repeat in a loop.reverse- Whether the animation should be played in reverse (from start to end and then continuously from end to start).src- The lottie animation source.
Events
on_error- Fires when an error occurs while loading the Lottie animation.
Properties
animateclass-attributeinstance-attribute
animate: bool = TrueWhether the animation should be played automatically.