I just got the same issue, If you are working with the StateMachineController.formArtboard
StateMachineController.fromArtboard(artboard, 'loadingState');
the name that you should enter in to the code, if you are working with the state machene
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:rive/rive.dart';
class Loader extends StatefulWidget {
const Loader({Key? key}) : super(key: key);
@override
_LoaderState createState() => _LoaderState();
}
class _LoaderState extends State<Loader> {
Artboard? _riveArtboard;
StateMachineController? _controller;
SMIInput<bool>? _isLoading;
@override
void initState() {
super.initState();
_loadRiveFile();
}
Future<void> _loadRiveFile() async {
await RiveFile.initialize();
final data = await rootBundle.load('assets/iconLoading.riv');
final file = RiveFile.import(data);
final artboard = file.mainArtboard;
var controller = StateMachineController.fromArtboard(artboard, 'loadingState');
if (controller != null) {
artboard.addController(controller);
_isLoading = controller.findInput('isLoading');
_isLoading?.value = true;
}
if (mounted) {
setState(() => _riveArtboard = artboard);
}
}
void startLoading() {
_isLoading?.value = true;
}
void stopLoading() {
if (mounted) {
setState(() {
_isLoading?.value = false;
});
}
}
@override
void dispose() {
_controller?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Center(
child: SizedBox(
width: 75,
height: 75,
child: _riveArtboard == null
? const CircularProgressIndicator()
: Rive(alignment: Alignment.center, artboard: _riveArtboard!),
),
);
}
}
Always be aware about namings.