Skip to content

chore: Rive migration - #66

Closed
NonymousMorlock wants to merge 10 commits into
agtrlabs:mainfrom
NonymousMorlock:rive-migration
Closed

chore: Rive migration#66
NonymousMorlock wants to merge 10 commits into
agtrlabs:mainfrom
NonymousMorlock:rive-migration

Conversation

@NonymousMorlock

Copy link
Copy Markdown
Collaborator

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

Replaces the standard `flutter_gen/gen_l10n` localization with a custom `arb` based implementation. This change introduces hand-written localization files for English (`en`) and Spanish (`es`).

The previous `l10n.dart` barrel file, which exported from `flutter_gen`, has been removed. All import paths throughout the application and tests have been updated to point to the new custom `app_localizations.dart` file.
This commit introduces a Python script for the LLDB debugger (`flutter_lldb_helper.py`) and its corresponding import command (`flutter_lldbinit`).

The script sets a breakpoint on `NOTIFY_DEBUGGER_ABOUT_RX_PAGES`. When triggered, it writes to the memory pages designated as readable and executable (RX), allowing the debugger to handle them correctly and prevent crashes during debugging sessions.
The Rive animation file for the small lake on a rainy day has been updated. A backup of the previous version is included as 'small_lake_on_a_rainy_day.bk.riv'.

- The previous version did not have a default state machine. This new version adds a default state machine
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 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