Tempo de execução do Rive para Flutter. Este pacote fornece funcionalidades de tempo de execução para gráficos Rive criados com o editor Rive disponível em https://rive.app
Orientação gerada a partir de informações públicas. Apenas para referência.
Rive é um pacote do Flutter que permite o renderização em tempo de execução de animações interativas e gráficos criados com o editor Rive. Ele permite que desenvolvedores integrem animações vetoriais suaves e leves em seus aplicativos em múltiplas plataformas. O pacote oferece suporte à reprodução de animação em tempo real, gerenciamento de estado e design responsivo, tornando-o ideal para interfaces dinâmicas e ativos de jogos. Com suporte para Android, iOS, Web, macOS, Windows e Linux, o Rive garante desempenho consistente e fidelidade visual. Foi projetado para integração perfeita com aplicativos Flutter usando APIs simples.
Casos de uso
interfaces de aplicativos interativas
animações de personagens de jogos
Indicadores de carregamento
Experiências de onboarding
Botões animados
Micro-interactions
Principais recursos
Animações baseadas em vetores
Reprodução em tempo real
Suporte de máquina de estado
Compatibilidade multiplataforma
Desempenho leve
Integração fácil com Flutter
Indicado para
Designers de UI/UX
Desenvolvedores de jogos
Criadores de aplicativos móveis
Desenvolvedores web
Projetos focados em animação
Protótipos interativos
Considerações
Requer o editor Rive para criação de ativos
Limitado ao formato de arquivo Rive (.riv)
Pode ser necessário aprender o sistema de animação do Rive
O desempenho depende da complexidade da animação
Não adequado para imagens estáticas
Melhor usado com fluxos de trabalho de design compatíveis com Rive
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
Rive Flutter
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:
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 appcd 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 = (awaitFile.asset(
'assets/rewards.riv',
// Choose which renderer to use
riveFactory: Factory.rive,
))!;
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:
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
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.
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.
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:
Run flutter clean
Run flutter pub get
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.