-
Notifications
You must be signed in to change notification settings - Fork 222
Description
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
- Create a Flutter project:
flutter create rive_issue --platforms web- Add rive dependency (from rive_issue):
dart pub add rive-
Download the
.rivfrom JC Toon's Login Screen Character from the Rive Marketplace. -
Save the
login_screen_character.rivwithin rive_issue/assets. -
Declare the
login_screen_character.rivin the pubspec.yaml:
# rive_flutter/pubspec.yaml
# ...
flutter:
uses-material-design: true
assets:
- assets/login_screen_character.riv- Replace the entire
main.dartwith 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,
),
),
),
);
}
}
-
Run the application and observe how the Rive character doesn't react to the fail trigger.
-
Replace the
main.dartfile 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,
),
),
),
);
}
}
- Notice how the fail trigger now has effect.
Source .riv/.rev file
- Download from JCToon's https://rive.app/marketplace/3469-7899-login-screen-character/
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