Stack([
Image.asset(
"assets/Icon/Checkbox.png",
color: uncheckedColor,
height: 22,
width: 22,
),
Image.asset(
"assets/Icon/fullyComplete1.gif",
color: uncheckedColor,
scale: 2.5,
opacity: const AlwaysStoppedAnimation<double>(1.0),
height: 22,
width: 22,
gaplessPlayback: true,
)
])
我想播放 GIF 文件 1 或 2 秒,然后我必须显示 png 文件。
我怎样才能实现它?
可以,这个解决方案很简单:
在顶级类中添加新变量
var show = false;
之后添加这个功能:
@override
void initState() {
Future.delayed(const Duration(seconds: 2), () {
setState(() => show = true);
});
super.initState();
}
现在添加您的代码
Stack([
show ? Image.asset(
"assets/Icon/Checkbox.png",
color: uncheckedColor,
height: 22,
width: 22,
) :
Image.asset(
"assets/Icon/fullyComplete1.gif",
color: uncheckedColor,
scale: 2.5,
opacity: const AlwaysStoppedAnimation<double>(1.0),
height: 22,
width: 22,
gaplessPlayback: true,
)
])