我正在尝试使该gif在单击浮动操作按钮时出现,并在按下ok后再次弹出它:https://66.media.tumblr.com/1ce23970665b7736bd857720ebf5a5b2/tumblr_pp3sftPVIy1wb1n5x_540.gif问题是,当我单击“确定”并重新单击浮动操作按钮时,gif将从上次按“确定”时停止停止。我希望每次单击浮动操作按钮时都从头开始。我怎样才能做到这一点?这是代码:
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"),
),
EDIT:我遵循第一个答案,并尝试如下在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"),
),