Skip to main content
The easiest way to integrate Rive animations and state machines into your application is via the RiveAnimation widget mentioned throughout the runtime help docs. However, there are cases where you may want to set up animation or state machine controllers associated with the Rive widget before the Artboard is rendered. Check out below for other ways to integrate Rive into your Flutter applications:

Alternative Methods

File loading

If you want to load in the .riv file from the rootBundle, you’ll need to import the data yourself. The main pattern here is:
1

Load in the bytes of the `.riv` file

2

Use the `RiveFile` class to parse the data and get a reference to the file

3

Create a reference to the Artboard you want to display, from that file

4

(Optional) Associate controllers to an Artboard (i.e `StateMachineController`)

5

Render the `Rive` widget with the artboard reference

1

Load in the bytes from .riv

2

Use RiveFile to parse bytes

3

Create an Artboard reference

4

Associate controllers to an Artboard

If you’re looking to just play a specific animation:
If you’re looking to play a state machine:
5

Render the Rive widget

Important: Note above that when connecting the Artboard to the Rive widget, you will need to call .instance() on it. This will allow any component instances to render within the canvas space appropriately

Complete Example

Altogether, this pattern might look like the following snippet below: