Lottie ThorVG for Flutter

Lottie ThorVG for Flutter

This Lottie for Flutter uses ThorVG as a renderer, provides a high performance and compact size.

  • 🖼️ Supports Lottie animation (JSON)
  • 👑 Based on C++ Native Function
  • 🍃 Lower CPU & Memory usage
  • ⚡ Higher frame rates

🚧 Comming soon

  • Built-in DotLottie loader (.lottie)
  • Supports C++ multi-threading
  • Less application binary size
  • Web, MacOS and Windows port

Benchmark

We've compared lottie-thorvg with lottie-flutter, we found approximately +12% improvement in frame rates of single animation. (300x300 in 'Pixel 3a' emulator)

Usage

lottie-thorvg aims to maintain the same interface as lottie-flutter. If you are currently using them, you can utilize the code by simply replacing the import statement with import 'package:lottie_thorvg/lottie.dart'.

import 'package:lottie_thorvg/lottie.dart';
// ...
class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Column(
          children: [
            // Load a Lottie animation from the assets
            Lottie.asset('assets/lottie/dancing_star.json'),

            // Load a Lottie animation from a url
            Lottie.network(
              'https://lottie.host/6d7dd6e2-ab92-4e98-826a-2f8430768886/NGnHQ6brWA.json'
            ),
          ],
        ),
      ),
    );
  }
}

License

MIT

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add lottie_thorvg

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  lottie_thorvg: ^0.0.1

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:lottie_thorvg/lottie.dart';
import 'package:lottie_thorvg/thorvg.dart';
import 'package:lottie_thorvg/thorvg_flutter_bindings_generated.dart';
import 'package:lottie_thorvg/utils.dart'; 

Download details:

Author: tinyjin

Source: https://github.com/tinyjin/lottie-thorvg

#flutter #ios #android 

Lottie ThorVG for Flutter
3 Likes1.05 GEEK