Skip to content

Controller ignoring trigger when immediately fired onInit #491

@alestiago

Description

@alestiago

Description

Firing an input trigger when the controller is added has no effect (the trigger get's fully ignored).

  void _onRiveInit(Artboard artboard) {
    final controller = StateMachineController.fromArtboard(
      artboard,
      'State Machine 1',
    )!;
    artboard.addController(controller);
    controller.getTriggerInput('fail')!.fire(); // Gets dropped, doesn't have any effect.
  }

Keep reading for further context.

Steps To Reproduce

  1. Create a Flutter project:
flutter create rive_issue --platforms web
  1. Add rive dependency (from rive_issue):
dart pub add rive
  1. Download the .riv from JC Toon's Login Screen Character from the Rive Marketplace.

  2. Save the login_screen_character.riv within rive_issue/assets.

  3. Declare the login_screen_character.riv in the pubspec.yaml:

# rive_flutter/pubspec.yaml

# ...

flutter:
  uses-material-design: true
  assets:
    - assets/login_screen_character.riv
  1. Replace the entire main.dart with the folling example:
import 'package:flutter/material.dart';
import 'package:rive/rive.dart';

void main() {
  runApp(const _Example());
}

class _Example extends StatelessWidget {
  const _Example();

  void _onRiveInit(Artboard artboard) {
    final controller = StateMachineController.fromArtboard(
      artboard,
      'State Machine 1',
    )!;
    artboard.addController(controller);
    controller.getTriggerInput('fail')!.fire(); // Gets dropped, doesn't have any effect.
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Rive Example')),
        body: Center(
          child: RiveAnimation.asset(
            'assets/login_screen_character.riv',
            fit: BoxFit.cover,
            animations: const ['idle'],
            onInit: _onRiveInit,
          ),
        ),
      ),
    );
  }
}
  1. Run the application and observe how the Rive character doesn't react to the fail trigger.

  2. Replace the main.dart file with the following example:

import 'package:flutter/material.dart';
import 'package:rive/rive.dart';

void main() {
  runApp(const _Example());
}

class _Example extends StatelessWidget {
  const _Example();

  void _onRiveInit(Artboard artboard) {
    final controller = StateMachineController.fromArtboard(
      artboard,
      'State Machine 1',
    )!;
    artboard.addController(controller);
    WidgetsBinding.instance.addPostFrameCallback((_) {
      controller.getTriggerInput('fail')!.fire(); // Now, the fail trigger has effect.
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Rive Example')),
        body: Center(
          child: RiveAnimation.asset(
            'assets/login_screen_character.riv',
            fit: BoxFit.cover,
            animations: const ['idle'],
            onInit: _onRiveInit,
          ),
        ),
      ),
    );
  }
}
  1. Notice how the fail trigger now has effect.

Source .riv/.rev file

Note: I couldn't attach it to the issue since I got the error "GitHub file type not allowed .riv"

Expected behavior

Either:
(A) The trigger event should have some effect (as with postFrameCallback)
(B) Include Dart documentation on when the controller is ready to accept inputs, currently artboard.addController documentation is quite limited:

  /// Add an animation controller to this artboard. Playing will be scheduled if
  /// it's already playing.
  bool addController(RiveAnimationController controller) {

Screenshots

Without postFrameCallback (no effect):

Screen.Recording.2025-07-14.at.10.40.31.mov

With postFrameCallback (does trigger):

Screen.Recording.2025-07-14.at.10.38.05.mov

Device & Versions

  • rive 0.13.20
# pubspec.lock
  rive:
    dependency: "direct main"
    description:
      name: rive
      sha256: "2551a44fa766a7ed3f52aa2b94feda6d18d00edc25dee5f66e72e9b365bb6d6c"
      url: "https://pub.dev"
    source: hosted
    version: "0.13.20"
  rive_common:
    dependency: transitive
    description:
      name: rive_common
      sha256: "2ba42f80d37a4efd0696fb715787c4785f8a13361e8aea9227c50f1e78cf763a"
      url: "https://pub.dev"
    source: hosted
    version: "0.4.15"
  • flutter doctor summary:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.32.0, on macOS 15.5 24F74 darwin-arm64, locale en-ES)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2025.1)
[✓] VS Code (version 1.101.2)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!

Additional context

  • N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions