Skip to main content
J
4mo ago

Riv runtime animation different

I have an animation that has 3 timelines the first 2 are one-shot and the last is a loop. Everything looks fine in editor but when I run it in runtime using flutter, the loop does not play only the first 2 timelines.

5 replies
J
4mo ago

Do you mind sharing the .rev and your Flutter code so I can take a closer look?

J
(edited) 4mo ago

Yea no problem, this plays the selected riv animation but for some reason it doesnt play the loop timeline. Also if i do a artboard and select the third item animation list it does play so it is there.


class AnimationPreview extends StatelessWidget {
final Uint8List? bytes;
final bool isLoading;

const AnimationPreview({required this.bytes, required this.isLoading}); @override Widget build(BuildContext context) { return Container( height: 200, margin: const EdgeInsets.all(16), decoration: BoxDecoration( border: Border.all(color: Colors.red, width: 2), borderRadius: BorderRadius.circular(10), ), child: isLoading ? const Center(child: CircularProgressIndicator()) : bytes != null ? Builder(builder: (context) { // Convert the Uint8List to ByteData. final byteData = ByteData.view( bytes!.buffer, bytes!.offsetInBytes, bytes!.lengthInBytes, ); // Import the animation from the ByteData. final file = RiveFile.import(byteData); return RiveAnimation.direct(file); }) : const Center( child: Icon(Icons.animation, size: 60, color: Colors.red)), ); } }

bmw_m_logo.rev
254 KB
J
4mo ago

After doing some digging I have come to the conclusion that the editor is pretty much different from how runtime is handled. Which the way I should handle loop animations should be with an event trigger?

4mo ago

Can you take a look at this example and tell me if it's working how you expect it to? https://zapp.run/edit/rive-out-of-band-assets-fonts-z19a062619b0?entry=lib/main.dart&file=lib/main.dart:4203-4211

I think the difference might be that I'm setting the state machine name in mine.

J
4mo ago

Yes, sir. Was just about to reply to this after adding the stateMachine I notice it played like it should. Interesting so I dont need the eventTrigger than. Thank you also for setting that example above this is confirm that by adding the StateMachineController it plays fine.