搜索插件、代码仓与 APP 分类

rive 封面
插件详情v0.14.11

rive

Rive Flutter 运行时。此包为使用 Rive 编辑器(可在 https://rive.app 获取)创建的 Rive 图形提供运行时功能。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
55.2万
喜欢数
1950
Pub 分数
140

安装插件

flutter pub add rive

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Rive 是一个 Flutter 包,可实现使用 Rive 编辑器创建的交互式动画和图形的运行时渲染。它使开发者能够将流畅、轻量级的矢量动画集成到其跨多个平台的应用程序中。该包支持实时动画播放、状态管理和响应式设计,非常适合动态 UI 和游戏资源。Rive 支持 Android、iOS、Web、macOS、Windows 和 Linux,确保一致的性能和视觉保真度。它专为与 Flutter 应用程序无缝集成而设计,使用简单的 API。

适合场景

  • 交互式应用程序界面
  • 游戏角色动画
  • 加载指示器
  • 入门体验
  • 动画按钮
  • Micro-interactions

主要特点

  • 基于向量的动画
  • 实时播放
  • 状态机支持
  • 跨平台兼容性
  • 轻量级性能
  • 轻松集成 Flutter

适合对象

  • UI/UX 设计师
  • 游戏开发者
  • 移动应用开发者
  • Web 开发人员
  • 以动画为重点的项目
  • 交互式原型

使用建议

  • 资产创建需要 Rive 编辑器
  • 限制为 Rive 文件格式 (.riv)
  • 可能需要学习 Rive 的动画系统
  • 性能取决于动画的复杂程度
  • 不适用于静态图像
  • 最好与兼容 Rive 的设计工作流程一起使用

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Pub Version Build Status Discord badge Twitter handle

Rive Flutter

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.

Table of contents

Overview of Rive

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:

Getting started

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:

Choosing a Renderer

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 renderer
  • Factoy.flutter for the Flutter renderer

For more information and additional consideration, see Specifying a Renderer.

Note on the Impeller 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:

  1. Try running the Flutter app with the --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
  1. Try running the Flutter app on the latest master channel. It is possible that visual bugs may be resolved on the latest Flutter commits, but not yet released in the beta or stable channel.
  2. If you are still seeing visual discrepancies with just the Impeller renderer on the latest master branch, we recommend raising a detailed issue to the Flutter Github repo with a reproducible example, and other relevant details that can help the team debug any possible issues that may be present.

Supported platforms

Platform Flutter Renderer Rive Renderer
iOS ✅ ✅
Android ✅ ✅
macOS ✅ ✅
Windows ✅ ✅
Linux ✅ ✅
Web ✅ ✅

Be sure to read the platform specific considerations for the Rive Flutter package.

Awesome Rive

For even more examples and resources on using Rive at runtime or in other tools, checkout the awesome-rive repo.

Troubleshooting

The required native libraries should be automatically downloaded during the build step (flutter run or flutter build). If you encounter issues, try the following:

  1. Run flutter clean
  2. Run flutter pub get
  3. Run flutter run

Alternatively, 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.

Building rive_native

By 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.

Testing

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.

Contributing

We love contributions and all are welcome! 💙

Issues

Rive Flutter Legacy Runtime

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.

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目