This is a significant update for Rive Flutter. We’ve completely removed all of the Dart code that was used for the Rive runtime and replaced it with our underlying C++ Runtime. See the Rive Native for Flutter page for more details.
This has resulted in a numbers of changes to the underlying API, and a large portion of the code base that was previously accessible through Dart is now implemented in C++ through FFI.
The provided Factory determines the renderer that will be used. Use Factory.rive for the Rive renderer or Factory.flutter for the shipped Flutter renderer (Skia or Impeller).
Vector Feathering only works with the Rive Renderer.
Key Changes:
Creating a Rive File now requires a factory (Factory.rive or Factory.flutter)
Replace RiveFile.import with File.decode() which returns a Future<File>
Consider using Data Binding instead of events for more advanced use cases.
RiveEvent has been removed and replaced with Event. Event is a sealed class with two options:
OpenUrlEvent
GeneralEvent
Registering an event listener:
Rive Events: New API
Copy
Ask AI
// New APIfinal controller = RiveWidgetController(_riveFile!);controller?.stateMachine.addEventListener(_onRiveEvent);void _onRiveEvent(Event event) { // Do something with the event}
Rive Events: New API
Copy
Ask AI
// New APIfinal controller = RiveWidgetController(_riveFile!);controller?.stateMachine.addEventListener(_onRiveEvent);void _onRiveEvent(Event event) { // Do something with the event}
Rive Events: Old API
Copy
Ask AI
// Old APIfinal controller = StateMachineController.fromArtboard(artboard, 'State Machine 1')!;controller.addEventListener(_onRiveEvent);void _onRiveEvent(RiveEvent event) { // Do something with the event}
Accessing properties returns Map<String, CustomProperty>. CustomProperty is also a sealed class with options:
CustomNumberProperty
CustomBooleanProperty
CustomStringProperty
All of these have a value field. On the Event class, there are convenient accessors:
Copy
Ask AI
// Convenient accessorsevent.property(name); // Returns a CustomPropertyevent.numberProperty(name); // Returns a CustomNumberPropertyevent.booleanProperty(name); // Returns a CustomBooleanPropertyevent.stringProperty(name); // Returns a CustomStringProperty
The FileAssetLoader class and all its subclasses have been removed:
CDNAssetLoader
LocalAssetLoader
CallbackAssetLoader
FallbackAssetLoader
Out-of-band Asset Loading
Out-of-band Asset Loading: New API
Copy
Ask AI
// New APIassetLoader: (asset, bytes) { /* sync work only but can call async functions */ }riveFactory.decodeImage(bytes) // or asset.decode(bytes)asset.renderImage(someImage) // returns bool for success
Out-of-band Asset Loading: New API
Copy
Ask AI
// New APIassetLoader: (asset, bytes) { /* sync work only but can call async functions */ }riveFactory.decodeImage(bytes) // or asset.decode(bytes)asset.renderImage(someImage) // returns bool for success
Out-of-band Asset Loading: Old API
Copy
Ask AI
// Old APIassetLoader: (asset, bytes) async { /* async work */ }ImageAsset.parseBytes(bytes)asset.image = someImage;
Key Changes:
assetLoader can no longer be an asynchronous lambda
ImageAsset.parseBytes(bytes) → riveFactory.decodeImage(bytes) or asset.decode(bytes)
FontAsset.parseBytes(bytes) → riveFactory.decodeFont(bytes) or asset.decode(bytes)
AudioAsset.parseBytes(bytes) → riveFactory.decodeAudio(bytes) or asset.decode(bytes)
ImageAsset.image = value → ImageAsset.renderImage(value) (returns boolean)
FontAsset.font = value → FontAsset.font(value) (returns boolean)
AudioAsset.audio = value → AudioAsset.audio(value) (returns boolean)
We recommend using Data Binding instead to update text at runtime.
It’s no longer possible to access a TextValueRun object directly. Use these methods instead to access the String value:
Get/Set Text Run Value
Copy
Ask AI
final controller = RiveWidgetController(riveFile);final artboard = controller.artboard;// Get a text run valueartboard.getText(value)artboard.getText(value, path: path)// Set a text run valueartboard.setText(value)artboard.setText(value, path: path)