首页 > 解决方案 > 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.

标签: flutterwebp

解决方案


能够通过执行 ImageWithWebPAsset.image.evict() 重新启动动画


推荐阅读