Widgets

Rive

Rive

Renders a Rive animation from a .riv file — vector animations and interactive state machines. Backed by the Flet Rive extension, so the rive extension must be enabled in ruflet.yaml:

extensions:
  - rive

Example

rive(
  "https://cdn.rive.app/animations/vehicles.riv",
  width: 300,
  height: 300,
  fit: "contain",
  speed_multiplier: 1.0,
  placeholder: progress_ring()
)

The first positional argument is the src, so rive("a.riv") and rive(src: "a.riv") are equivalent. src may be a network URL or a bundled asset path.

Drive a specific artboard and state machine:

rive(
  "assets/character.riv",
  art_board: "Main",
  state_machines: ["State Machine 1"],
  use_art_board_size: true
)

Properties

  • srcrequired path to the .riv file (network URL or asset path).
  • placeholder — a control shown while the file loads (e.g. progress_ring()).
  • art_board — the name of the artboard to display; defaults to the file's main

artboard.

  • animations — an array of animation names to play.
  • state_machines — an array of state machine names to run.
  • fit — how the animation fits its box: "contain", "cover", "fill",

"fit_width", "fit_height", "none", "scale_down".

  • alignment — alignment of the animation within its box

({ x:, y: }, each from -1.0 to 1.0).

  • speed_multiplier — playback speed multiplier (default 1.0).
  • use_art_board_size — size the widget to the artboard's intrinsic size

instead of the available space (default false).

  • headers — a hash of HTTP headers used when fetching a network src.
  • clip_rect — a clip rectangle ({ left:, top:, right:, bottom: }).
  • expand — fill the available space in a row/column.
  • width / height — fixed size when not expanding.
  • tooltip, visible, opacity, rtl, disabled — the usual layout

properties.

Use the Ruflet wire names art_board and use_art_board_size; the current DSL passes extension properties through without renaming them.

Rive has no events or methods — playback is driven by animations, state_machines, and speed_multiplier.

Reference

  • Family: materials
  • Widget type: rive
  • Helper: rive

Complete API

Helpers

  • rive(src = ..., **props)

Accepted properties

  • align — Alignment of the control within its parent.
  • alignment — Alignment of the content within the control.
  • animate_align — Animates alignment changes.
  • animate_margin — Animates margin changes.
  • animate_offset — Animates offset changes.
  • animate_opacity — Animates opacity changes.
  • animate_position — Animates position changes.
  • animate_rotation — Animates rotation changes.
  • animate_scale — Animates scale changes.
  • animate_size — Animates size changes.
  • animations — Sets the animations property.
  • art_board — Sets the art board property.
  • aspect_ratio — Width-to-height ratio to maintain.
  • badge — Badge drawn on the corner of the control.
  • bottom — Bottom offset when positioned inside a stack.
  • clip_rect — Sets the clip rect property.
  • col — Responsive column span (1-12) per breakpoint.
  • data — Arbitrary value you can attach to the control and read back in handlers.
  • disabled — Disables interaction when true.
  • expand — Fills the available space along the parent's main axis when true.
  • expand_loose — Like expand, but only grows up to the child's natural size.
  • fit — Sets the fit property.
  • headers — Sets the headers property.
  • height — Fixed height in logical pixels.
  • key — Stable identity used to preserve state across rebuilds.
  • left — Left offset when positioned inside a stack.
  • margin — Outer spacing around the control.
  • offset — Translation offset applied to the control.
  • opacity — Opacity from 0.0 (transparent) to 1.0 (opaque).
  • placeholder — Sets the placeholder property.
  • right — Right offset when positioned inside a stack.
  • rotate — Rotation applied to the control.
  • rtl — Renders right-to-left when true.
  • scale — Scale transform applied to the control.
  • size_change_interval — Throttle interval for on_size_change, in ms.
  • speed_multiplier — Sets the speed multiplier property.
  • src — Source URL or asset path of the image.
  • state_machines — Sets the state machines property.
  • tooltip — Text shown on hover/long-press.
  • top — Top offset when positioned inside a stack.
  • use_art_board_size — Sets the use art board size property.
  • visible — Hides the control when false.
  • width — Fixed width in logical pixels.

Events

  • on_animation_end — Fired when an animation completes.
  • on_size_change — Fired when the control's size changes.

Wire reference

  • Family: materials
  • Widget type: rive