Home:ALL Converter>How can I run this setState function for say every 1 sec

How can I run this setState function for say every 1 sec

Ask Time:2018-06-08T21:57:36         Author:Taio

Json Formatter

void play(){    
setState(() {
  tween = new VibesTween(
    tween.evaluate(animation),
    new Wave.random(size, random),
  );
  animation.forward(from: 0.0);
});
}

I need to call this play function which animates a particular animation. The only problem is it runs every time I click a button. I need it to call state every 1 second and rerender the animation again for every second. How can I achieve this?

Author:Taio,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50762295/how-can-i-run-this-setstate-function-for-say-every-1-sec
Edman :

You don't really need to call setState every second, you just need a repeating animation. And AnimationController has a repeat method for cases like this.\n\nTo set it off in its most basic form you can just call,\n\nanimationController.repeat();\n\n\nBut you can also provide overrides, as in\n\nanimationController.repeat(min: 0.0, max: 1.0, period: Duration(seconds: 1));\n",
2018-06-08T14:15:16
yy