I'm trying to show an animation from my riv flare. It was really simple in FlareActor and flr file. But can't show my animation with riv. I have 2 animations in my riv file. They are anim1 and anim2. I'm trying to show anim1 as default. Then trying to change it according to conditions. Here is my code snippet.
late RiveAnimationController? _controller;
Artboard? _riveArtboard;
@override
void initState() {
super.initState();
_loadRiveFile();
}
void _loadRiveFile() async {
await rootBundle.load('assets/animations/anim_file.riv').then(
(data) async {
final file = RiveFile.import(data);
final _artboard = file.mainArtboard;
_artboard.addController(_controller = SimpleAnimation('anim1'));
setState(() => _riveArtboard = _artboard);
},
);
}
This is build func:
GestureDetector(
onTap: () => {getStatus},
child: _riveArtboard == null ? const SizedBox.shrink(): Rive(artboard: _riveArtboard!))),
What I'm missing? Or how can I show my animation? Also I tried set controllers but it didn't work.