All Projects → xvrh → Lottie Flutter

xvrh / Lottie Flutter

Licence: mit
Render After Effects animations natively on Flutter. This package is a pure Dart implementation of a Lottie player.

Programming Languages

dart
5743 projects

Projects that are alternatives of or similar to Lottie Flutter

Pickr
🎨 Flat, simple, multi-themed, responsive and hackable Color-Picker library. No dependencies, no jQuery. Compatible with all CSS Frameworks e.g. Bootstrap, Materialize. Supports alpha channel, rgba, hsla, hsva and more!
Stars: ✭ 3,759 (+746.62%)
Mutual labels:  widget
Flutter badges
A flutter package for creating badges.
Stars: ✭ 391 (-11.94%)
Mutual labels:  widget
Qt Advanced Docking System
Advanced Docking System for Qt
Stars: ✭ 422 (-4.95%)
Mutual labels:  widget
Direct Select Flutter
DirectSelect is a selection widget with an ethereal, full-screen modal popup displaying the available choices when the widget is interact with. https://dribbble.com/shots/3876250-DirectSelect-Dropdown-ux
Stars: ✭ 360 (-18.92%)
Mutual labels:  widget
Sofi
an OS agnostic UI module for Python
Stars: ✭ 378 (-14.86%)
Mutual labels:  widget
Tabulator
Interactive Tables and Data Grids for JavaScript
Stars: ✭ 4,329 (+875%)
Mutual labels:  widget
Stacklayoutmanager
customized layoutmanager,let item pile up like stackview/类似最美有物卡片堆叠效果
Stars: ✭ 343 (-22.75%)
Mutual labels:  widget
Sliding Panel
Android sliding panel that is part of the view hierarchy, not above it.
Stars: ✭ 433 (-2.48%)
Mutual labels:  widget
Zhumulangma
高仿喜马拉雅Android客户端,单activity多fragme组件化架构(新增ams版)
Stars: ✭ 377 (-15.09%)
Mutual labels:  lottie
Projectx
所有个人开源项目合集,便于管理及维护。
Stars: ✭ 417 (-6.08%)
Mutual labels:  widget
Flutter Settings Ui
Create native settings for Flutter app in a minutes.
Stars: ✭ 363 (-18.24%)
Mutual labels:  widget
Functional widget
A code generator to write widgets as function without loosing the benefits of classes.
Stars: ✭ 374 (-15.77%)
Mutual labels:  widget
Scriptable
scriptable widget
Stars: ✭ 405 (-8.78%)
Mutual labels:  widget
Flutter radial menu
A simple animated radial menu widget for Flutter.
Stars: ✭ 359 (-19.14%)
Mutual labels:  widget
Styled widget
Simplifying widget style in Flutter.
Stars: ✭ 424 (-4.5%)
Mutual labels:  widget
React Native Messenger
Facebook Messenger Implementation using react-native
Stars: ✭ 351 (-20.95%)
Mutual labels:  lottie
Dragpointview
A draggable PointView for Android.
Stars: ✭ 401 (-9.68%)
Mutual labels:  widget
Urweatherview
Show the weather effects onto view written in Swift4.2
Stars: ✭ 439 (-1.13%)
Mutual labels:  lottie
Avatarview
A circular Image View with a lot of perks. Including progress animation and highlight state with borders and gradient color.
Stars: ✭ 429 (-3.38%)
Mutual labels:  widget
Githubcontributionsios
Show off your GitHub contributions from your lock screen 📱
Stars: ✭ 410 (-7.66%)
Mutual labels:  widget

Lottie for Flutter

pub package

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';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: ListView(
          children: [
            // Load a Lottie file from your assets
            Lottie.asset('assets/LottieLogo1.json'),

            // Load a Lottie file from a remote url
            Lottie.network(
                'https://raw.githubusercontent.com/xvrh/lottie-flutter/master/example/assets/Mobilo/A.json'),

            // Load an animation and its images from a zip file
            Lottie.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...

import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
  late final AnimationController _controller;

  @override
  void initState() {
    super.initState();

    _controller = AnimationController(vsync: this);
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: ListView(
          children: [
            Lottie.asset(
              'assets/LottieLogo1.json',
              controller: _controller,
              onLoaded: (composition) {
                // Configure the AnimationController with the duration of the
                // Lottie file and start the animation.
                _controller
                  ..duration = composition.duration
                  ..forward();
              },
            ),
          ],
        ),
      ),
    );
  }
}

See this file for a more comprehensive example.

Control the size of the Widget

The Lottie widget takes the same arguments and have the same behavior as the Image widget in term of controlling its size.

Lottie.asset(
  'assets/LottieLogo1.json',
  width: 200,
  height: 200,
  fit: BoxFit.fill,
)

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 LottieComposition.fromByteData to parse the file from a list of bytes.

This example shows how to load and parse a Lottie composition from a json file.

class MyWidget extends StatefulWidget {
  @override
  _MyWidgetState createState() => _MyWidgetState();
}

class _MyWidgetState extends State<MyWidget> {
  late final Future<LottieComposition> _composition;

  @override
  void initState() {
    super.initState();

    _composition = _loadComposition();
  }

  Future<LottieComposition> _loadComposition() async {
    var assetData = await rootBundle.load('assets/LottieLogo1.json');
    return await LottieComposition.fromByteData(assetData);
  }

  @override
  Widget build(BuildContext context) {
    return FutureBuilder<LottieComposition>(
      future: _composition,
      builder: (context, snapshot) {
        var composition = snapshot.data;
        if (composition != null) {
          return Lottie(composition: composition);
        } else {
          return Center(child: CircularProgressIndicator());
        }
      },
    );
  }
}

Custom drawing

This example goes low level and shows you how to draw a LottieComposition on a custom Canvas at a specific frame in a specific position and size.

class CustomDrawer extends StatelessWidget {
  final LottieComposition composition;

  const CustomDrawer(this.composition, {Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return CustomPaint(
      painter: _Painter(composition),
      size: Size(400, 400),
    );
  }
}

class _Painter extends CustomPainter {
  final LottieDrawable drawable;

  _Painter(LottieComposition composition)
      : drawable = LottieDrawable(composition);

  @override
  void paint(Canvas canvas, Size size) {
    var frameCount = 40;
    var columns = 10;
    for (var i = 0; i < frameCount; i++) {
      var destRect = Offset(i % columns * 50.0, i ~/ 10 * 80.0) & (size / 5);
      drawable
        ..setProgress(i / frameCount)
        ..draw(canvas, destRect);
    }
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) {
    return true;
  }
}

Modify properties at runtime

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.

class _Animation extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Lottie.asset(
      'assets/Tests/Shapes.json',
      delegates: LottieDelegates(
        text: (initialText) => '**$initialText**',
        values: [
          ValueDelegate.color(
            const ['Shape Layer 1', 'Rectangle', 'Fill 1'],
            value: Colors.red,
          ),
          ValueDelegate.opacity(
            const ['Shape Layer 1', 'Rectangle'],
            callback: (frameInfo) => (frameInfo.overallProgress * 100).round(),
          ),
          ValueDelegate.position(
            const ['Shape Layer 1', 'Rectangle', '**'],
            relative: Offset(100, 200),
          ),
        ],
      ),
    );
  }
}

Limitations

This port supports the same feature set as Lottie Android.

Flutter Web

Run the app with flutter run -d chrome --web-renderer canvaskit

See a preview here: https://xvrh.github.io/lottie-flutter-web/

More examples

See the example folder for more code samples of the various possibilities.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].