• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


25 Mar, 2025

Updated at 20 May, 2025

Flutter/Rive, State Machine. Animation works fine, event never triggers

Trying to test rive animations in flutter and use changable data based on rive triggers.

The rive file is a simple click animation and works fine but the event 'onRiveEvent' never fires so I can't make changes in data.

expected results: prints in Debug Console.

Gif with example

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

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State createState() => _HomePageState();
}

class _HomePageState extends State {
  // SMIInput? _booleanInput;
  void onRiveEvent(RiveEvent event) {
    print('sdasda');
    print(event);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: RiveAnimation.asset('assets/test2.riv',
            onInit: (Artboard artboard) {
          final controller =
              StateMachineController.fromArtboard(artboard, 'State Machine 1');
          controller!.addEventListener(onRiveEvent);
          artboard.addController(controller);
          // _booleanInput = controller.findInput('on');
        }),
      ),
    );
  }
}