一、疑难杂症
1、gif 如何停止播放
1 2
| Image.asset("assets/tasky_logo.gif", gaplessPlayback: false, fit: BoxFit.fill)
|
以上来源于:How to stop GIF loop in flutter?
我有一个设置,其中我有一个带有gif的警告对话框。当对话框打开时,我希望gif只播放一次,这是我用这篇文章中最好的答案实现的:
How to stop GIF loop in flutter?
问题是,当我重新打开对话框时,gif不会再次播放。解决如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| AssetImage image;
@override void initState() { super.initState(); image = AssetImage(widget.asset); print('${widget.asset} initState'); }
@override void dispose() { print('${widget.asset} dispose'); image.evict(); super.dispose(); }
|
以上参考来源于:Load gif animation multiple times, not play from the first frame
3、【Flutter】控制GIF播放
【Flutter】控制GIF播放
1 2 3 4 5
| Visibility( visible: isPlay, child: Image.asset("images/gif_player_demo.gif"), replacement: Image.asset("images/gif_player_demo.png"), );
|