v0.14.6rive
Rive Flutter 运行时。此包为使用 Rive 编辑器(可在 https://rive.app 获取)创建的 Rive 图形提供运行时功能。
Rive 的 Flutter 运行时
{"sdk":"flutter"}{"sdk":"flutter"}0.2.0-dev.2{"sdk":"flutter"}^5.0.0以下为英文项目原文快照,最新内容请访问 GitHub。
Pub Version Build Status Discord badge Twitter handle
Rive hero image
Rive Flutter is a runtime library for Rive, a real-time interactive design tool.
This library allows you to fully control Rive files in your Flutter apps and games.
Rive combines an interactive design tool, a new stateful graphics format, a lightweight multi-platform runtime, and a blazing-fast vector renderer. This end-to-end pipeline guarantees that what you build in the Rive Editor is exactly what ships in your apps, games, and websites.
For more information, check out the following resources:
See the Getting Started with Rive in Flutter documentation.
Example App
The rive package depends on rive_native, and the code on GitHub may reference an unpublished version of rive_native. To run the example app, we recommend using the published version from Pub unless you intend to build the native libraries locally (see Building rive_native).
dart pub unpack rive # Unpack the package source code and example app
cd rive/example # Navigate to the example folder
flutter create . # Create the platform folders
flutter pub get # Fetch dependencies
flutter run # Run the example app
For more information, see the Runtime sections of the Rive help documentation:
In Rive Flutter you have the option to choose either the Rive renderer, or the renderer that is used in Flutter (Skia or Impeller).
You choose a desired renderer when creating a Rive File object. All graphics that are then created from this File instance will use the selected renderer.
final riveFile = (await File.asset(
'assets/rewards.riv',
// Choose which renderer to use
riveFactory: Factory.rive,
))!;
Options:
Factory.rive for the Rive rendererFactoy.flutter for the Flutter rendererFor more information and additional consideration, see Specifying a Renderer.
Starting in Flutter v3.10, Impeller has replaced Skia to become the default renderer for apps on the iOS platform and may continue to be the default on future platforms over time. As such, there is a possibility of rendering and performance discrepencies when using the Rive Flutter runtime with platforms that use the Impeller renderer that may not have surfaced before. If you encounter any visual or performance errors at runtime compared to expected behavior in the Rive editor, we recommend trying the following steps to triage:
--no-enable-impeller flag to use the Skia renderer. If the visual discrepancy does not show when using Skia, it may be a rendering bug on Impeller. However, before raising a bug with the Flutter team, try the second point below👇flutter run --no-enable-impeller
| Platform | Flutter Renderer | Rive Renderer |
|---|---|---|
| iOS | ✅ | ✅ |
| Android | ✅ | ✅ |
| macOS | ✅ | ✅ |
| Windows | ✅ | ✅ |
| Linux | ✅ | ✅ |
| Web | ✅ | ✅ |
Be sure to read the platform specific considerations for the Rive Flutter package.
For even more examples and resources on using Rive at runtime or in other tools, checkout the awesome-rive repo.
The required native libraries should be automatically downloaded during the build step (flutter run or flutter build). If you encounter issues, try the following:
flutter cleanflutter pub getflutter runAlternatively, you can manually run the rive_native setup script. In the root of your Flutter app, execute:
dart run rive_native:setup --verbose --clean --platform macos
This will clean the rive_native setup and download the platform-specific libraries specified with the --platform flag. Refer to the Platform Support section above for details.
rive_nativeBy default, prebuilt native libraries are downloaded and used. If you prefer to build the libraries yourself, use the --build flag with the setup script. In the root of your Flutter app:
flutter clean # Important
flutter pub get
dart run rive_native:setup --verbose --clean --build --platform macos
See Building rive_native in the official docs for the required tooling per platform, supported --platform values, web specifics, and how to return to the prebuilt libraries.
Shared libraries are included in the download/build process. If you've done flutter run on the native platform, the libraries should already be available.
Otherwise, manually download the prebuilt libraries by doing:
dart run rive_native:setup --verbose --clean --platform macos
Specify the desired --platform, options are macos, windows, and linux.
Now you can run flutter test.
Optionally build the libraries if desired:
dart run rive_native:setup --verbose --clean --build --platform macos
If you encounter issues using rive_native in your tests, please reach out to us for assistance.
We love contributions and all are welcome! 💙
You can find the old runtime code here: https://github.com/rive-app/rive-flutter-legacy
The last published Pub release for this code is rive: 0.13.20.
The majority of the new runtime code now lives in the rive_native package.