rive-flutter
rive-flutter copied to clipboard
Rive animations do not respect TickerMode
Description
TickerMode [1] is used in flutter to turn off animations for a subtree. However, it appears that rive is not respecting the setting.
[1] https://master-api.flutter.dev/flutter/widgets/TickerMode-class.html
Steps To Reproduce
Steps to reproduce the behavior:
- Wrap the simple animation of the example app with a
TickerMode(enabled: false, child: ...)
:
TickerMode( // new
enabled: false, // new
child: const Center(
child: RiveAnimation.network(
'https://cdn.rive.app/animations/vehicles.riv',
fit: BoxFit.cover,
),
),
), // new
- Launch the app, navigate to that example
- observe that the animation is still running
Expected behavior
The animation shouldn't be running when TickerMode is off
/cc @dnfield
If the animations were to be driven off a AnimationController you'd get this feature for free as AnimationControllers stop ticking when TickerMode is off.
Hi @goderbauer, this should now be resolved in v0.11.14
Thanks for reporting the issue. Please reopen if you encounter an issues.
Hey @HayesGordon, it seems like the issue is not fixed.
The ticker is stopped when ticket mode is disabled on the creation of the render object.
However, afterward, the render object is attached without looking at the tickerModeEnabled
.
That leads to just starting the ticker.
I have created a small PR.
I have not added a test for the render object as I was not able to find an already existing test for that render object.
I hope that it is fine.