gpt4 book ai didi

flutter - 关闭并重新打开礼物后,使礼物从头开始

转载 作者:行者123 更新时间:2023-12-03 03:57:09 25 4
gpt4 key购买 nike

我试图使该gif在单击 float 操作按钮时出现,并在按下ok后再次弹出它:
https://66.media.tumblr.com/1ce23970665b7736bd857720ebf5a5b2/tumblr_pp3sftPVIy1wb1n5x_540.gif
问题是,当我单击“确定”并重新单击 float 操作按钮时,gif将从上次按“确定”时停止停止。我希望每次单击 float 操作按钮时都从头开始。我怎样才能做到这一点?这是代码:

floatingActionButton: FloatingActionButton(
child: Icon(Icons.healing),

onPressed: () {
showDialog(
context: context,
builder: (_) => Container(
height: 200.0,
child: NetworkGiffyDialog(
// key: keys[1],
image: Image.network(
gif,
fit: BoxFit.fitHeight,
),
title: Text("Exercises of breathing"),
description: Text(
'This will help you with breathing exercises to overcome anxiety attacks',
),
entryAnimation: EntryAnimation.RIGHT,
onOkButtonPressed: () {
Navigator.of(context).pop();
},
),
),
);
},
//child: new Text("Breathing exercise"),
),

编辑:我遵循第一个答案,并尝试如下在null值和gif链接之间进行切换,但是我仍然遇到相同的问题
floatingActionButton: FloatingActionButton(
child: Icon(Icons.healing),

onPressed: () {
setState(() => gif = giflink);
showDialog(
context: context,
builder: (_) => Container(
height: 200.0,
child: NetworkGiffyDialog(
// key: keys[1],
image: Image.network(
gif,
fit: BoxFit.fitHeight,
),
title: Text("Exercises of breathing"),
description: Text(
'This will help you with breathing exercises to overcome anxiety attacks',
),
entryAnimation: EntryAnimation.RIGHT,
onOkButtonPressed: () {
Navigator.of(context).pop();
setState(() => gif = null);
},
),
),
);
},
//child: new Text("Breathing exercise"),
),

最佳答案

您可以尝试的一件事是在动画(GIF持续时间)结束后(或如果用户取消),将变量gif用作setState的空值。

var gif = "https://theurlofyourgif.com/file.gif"

void doYourGIFLogic() {
// show it with a Navigator, or Opacity, or Visibility, etc
// wait for that animation (GIF duration) to be done
final NetworkImage provider = NetworkImage(gif);
provider.evict().then<void>((bool success) {
if (success) {
print('removed image!');
}
});
}

当用户再次使用FAB单击时,缓存将被清除,GIF应该从头开始。

关于flutter - 关闭并重新打开礼物后,使礼物从头开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60176038/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com