thorvg 1.0.0-beta.0 thorvg: ^1.0.0-beta.0 copied to clipboard
ThorVG Flutter Runtime
ThorVG for Flutter #
This package provides ThorVG runtime for Flutter, including efficient Lottie animation support based on a native API.
Currently, we only support Animation(Lottie) feature in this package.
Supported Platforms #
Platform | Architecture |
---|---|
Android | arm64-v8a, armeabi-v7a, x86_64 |
iOS | arm64, x86_64, x86_64(simulator) |
Usage #
Animation #
Lottie implementation 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:thorvg/thorvg.dart'
.
import 'package:thorvg/thorvg.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'
),
],
),
),
);
}
}
Generate Flutter binding #
If you change binding interface in these files
tvgFlutterLottieAnimation.h
tvgFlutterLottieAnimation.cpp
You always have to run following script:
# Run at first time
flutter pub get
# Generate bindings with ffigen
flutter pub run ffigen --config ffigen.yaml
You will have ./lib/src/thorvg_bindings_generated.dart
.
Build #
Specify the ThorVG version in .gitmodules
.
[submodule "thorvg"]
path = thorvg
url = git@github.com:thorvg/thorvg.git
branch = v0.14.x # Change to version you want
Then you can run following commands to align with that version before build.
git submodule init
git submodule update --remote
Android #
Android build requires NDK(LTS), please specify following build systems info.
# Build for Animation(Lottie)
cd lottie
sh flutter_build.android.sh $NDK $HOST_TAG $API
Check whether these files are gnerated:
android/src/main/arm64-v8a/libthorvg.so
android/src/main/armeabi-v7a/libthorvg.so
android/src/main/x86_64/libthorvg.so
iOS #
# Build for Animation(Lottie)
cd lottie
sh flutter_build.ios.sh
Check the file is generated:
ios/Frameworks/libthorvg.dylib