进度完成后,循环进度按钮会自动触发

时间:2019-01-23 11:36:00

标签: dart flutter

我有一个基于ontapdown和ontapup的循环工作进度按钮,但是我希望它在进度完成后触发。现在,它仅在进度完成并用户点击Up时触发。

This is the one i manage to do

onTapDown: (_) {
controller1.forward();
},

onTapUp: (_) {
  if (controller1.status ==
      AnimationStatus.forward) {
    controller1.reverse();
  } else if (controller1.status ==
      AnimationStatus.completed) {
    setState(() {
      controller1.value = 0.0;
      // widget.isClickCALLBOMBA = true;
      // controller1.reverse();
      Flushbar()
        ..title = allTranslations
            .text('success')
        ..message =
            "We will alert the bomba !"
        ..duration =
            Duration(seconds: 3)
        ..backgroundColor =
            Colors.red
        ..show(context);
    });
  }
},

1 个答案:

答案 0 :(得分:0)

您可以在AnimationController上添加一个侦听器,以在动画制作完成后做一些事情:

controller1.addStatusListener((status) {
  if (status != AnimationStatus.completed) {
    return;
  }

  //Animation is complete! Do completion stuff.
});