Search code examples
flutterwebp

Restarting WebP animation to first frame in Flutter


Is there a way to force a restart on an WebP animation?

After flutter engine added WebP support (https://github.com/flutter/flutter/issues/9857) I am able to loop a single animation.webp file successfully forever.

I want to restart the animation.webp animation for every onTouch() event of a widget.

I have a custom Visibility wrapper widget that properly continues the animation from the point it is hidden and becomes visible again, but the looping and timing does not work out perfectly all the time.

Have a feeling I may need to modify the flutter engine to support this.


Solution

  • Was able to restart the animation by doing an ImageWithWebPAsset.image.evict()