Skip to content

chore: Rive migration#1

Merged
NonymousMorlock merged 7 commits intomainfrom
rive-migration
Oct 22, 2025
Merged

chore: Rive migration#1
NonymousMorlock merged 7 commits intomainfrom
rive-migration

Conversation

@NonymousMorlock
Copy link
Owner

Description

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

This commit upgrades the Rive package from `^0.13.5` to the development version `^0.14.0-dev.11`.

As part of this upgrade, the plugin registration name has changed from `rive_common` to `rive_native` across all supported platforms (Linux, macOS, and Windows). The generated plugin registration files have been updated accordingly.
The Rive asset has been updated in the editor to leverage **data bindings** for properties and **state machine inputs** for state tracking, replacing the older implementation style.

This change aligns the asset with the best practices of the new Rive API, making it easier to manage complex property changes and state transitions in the Flutter application.
This commit refactors the `GameButton` widget to use the modern Rive API, replacing the old direct animation control with `RiveWidget` and `RiveWidgetController`.

Key changes include:

* **API Switch:** Replaced `RiveAnimation.direct` with `RiveWidget`.
* **Controller:** Switched from `StateMachineController` to the unified `RiveWidgetController`.
* **Asset Loading:** Updated asset loading from `RiveFile.import` to the new asynchronous `File.decode`.
* **Text & State Handling:** Migrated to the new **data binding** and **state machine input** listeners (`controller.dataBind`, `viewModelInstance.string('currentState')`) for setting button text and handling press/rest states, removing boilerplate manual controller management.
This commit refactors the background animation on the `LevelCompletePage` to use the new Rive API pattern.

The `LevelCompletePage` has been converted from a `StatelessWidget` to a `StatefulWidget` to manage the asynchronous asset loading lifecycle.

Key changes:
* **Widget Switch:** Replaced `RiveAnimation.asset` with `RiveWidget`.
* **Asset Loading:** Switched to the asynchronous `File.asset` and managed its state via `initState` and an `isInitialized` flag, displaying a loading indicator until ready.
* **Resource Management:** Added proper disposal of `File` and `RiveWidgetController` in `dispose()`.
* **Navigation Fix:** Updated the next level navigation to correctly access `levelData` via `widget.levelData`.
…Machine API

This commit refactors the Rive animation implementation within the `Hint` widget to align with the new Rive API.

Key changes:
* **Widget & Controller:** Replaced `RiveAnimation.direct` with `RiveWidget` and introduced `RiveWidgetController` for unified management.
* **Asset Loading:** Migrated from `RiveFile.import` to the modern asynchronous `File.decode`.
* **Input Access:** Switched from `StateMachineController.fromArtboard` and casting `SMIBool` to the simpler, direct access pattern using `artboard.stateMachine('name')` and `stateMachine.boolean('input')`.
* **Input Modification:** Replaced the imperative `change()` method on inputs with the direct value assignment using `input.value = ...`.
* **Resource Management:** Added disposal of the `RiveWidgetController` and all related Rive objects (`StateMachine`, `BooleanInput`) in the `dispose()` method for memory safety.
This commit removes the `lib/core/extensions/rive_extensions.dart` file.

The `TextExtension` became obsolete after migrating the Rive implementations (specifically `GameButton`) to the new API's built-in text functionality (`artboard.setText`) instead of using the custom extension to find `TextValueRun` components.
This commit finalizes the Rive migration by updating the asset initialization in `bootstrap.dart`.

The older `RiveFile.initialize()` has been replaced with the new, platform-specific `RiveNative.init()` to properly set up the native Rive rendering environment.

Additionally, `WidgetsFlutterBinding.ensureInitialized()` was added before the Rive and HydratedBloc initialization to ensure the necessary service bindings are available.
@NonymousMorlock NonymousMorlock merged commit dbc0692 into main Oct 22, 2025
1 of 2 checks passed
@NonymousMorlock NonymousMorlock deleted the rive-migration branch October 22, 2025 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant