Skip to main content

Lottie

The Lottie widget plays Lottie JSON animation files as vectors.
Use it to show lightweight vector animations on screen, such as loading spinners, icon motion, and illustrated animations.

Definition and role

The Lottie widget loads a Lottie JSON animation and plays it in the area you specify. Pick the source from an asset (a file bundled with the app), a file (a device path), or the network (a URL). You can also set autoplay, looping, reverse playback, frame rate, size, and fit.

  • Category: Contents
  • Default source type: asset
  • Default behavior: autoplay + loop
  • Default size (SizedBox): 300 wide, 150 tall

Features

FeatureDescription
Source selectionPick the Lottie JSON source to play from an asset, a file, or the network (URL).
Playback controlSet autoplay, looping, and reverse playback.
Frame rateSet the playback speed in fps. Leave it empty to use the value stored in the JSON file.
Size and fitSet the width and height, plus the fit mode and alignment inside that area.

How to use

  1. Open the Contents category in the left widget palette.
  2. Drag the Lottie item onto the canvas. (A default sample animation appears.)
  3. In the properties panel on the right, choose the source type (src) and enter the path or URL (name).
  4. Adjust autoplay (animate), looping (repeat), reverse playback (reverse), frame rate (frameRate), and size as needed.

Properties

PropertyDescriptionDefaultValue / Type
srcWhere the animation source livesassetasset, file, network (URL)
nameAsset path, file path, or network URL of the Lottie JSON to playEmptyString
animateWhether to play automatically once loadedtruetrue / false
frameRatePlayback frame rate in fps. Leave empty to use the JSON valueNot setNumber (minimum 1)
repeatWhether playback loops when it finishestruetrue / false
reverseWhether to play in reversefalsetrue / false
SizeDisplay size - a grouped property that sets width and height togetherNot setSize (width and height, Number in px)
fitHow the animation fits inside the size you setNot setfill, contain, cover, fitWidth, fitHeight, none, scaleDown
alignmentAlignment inside the areaNot set (center)Alignment value

Notes and tips

tip

Leave frameRate empty and the widget uses the frame rate stored in the Lottie JSON file. Change the source and the value may refresh automatically to match the new file.

warning

When the source path (name) is empty, the default sample animation appears instead. If the path or URL is wrong, or the file can't be found, an error message appears.

Learn more

tip

For the full set of Widget Controls (Property, Method, and Event) that drive this widget from a script, visit Lottie Widget Control.