I have a custom View in Android Studio that updates every x milliseconds using a custom animation. I'm now trying to implement this behaviour in Dart. This is how the animation is implemented in Android Java. (It represents only the animation logic and does nothing else)

public class ItemAnim extends CountDownTimer {

    public ItemAnim(long millisInFuture, long countdownInterval){
       super(millisInFuture, countdownInterval);

    public void onTick(long millisUntilFinished) {    
        // do anim stuff like setting a rotation angle variable etc...
        // listener.animate(...) code

I'm now looking for a very similar class in Dart/Flutter SDK.

i.e. a class that calls onTick(millisUntilFinished) every countdownInterval milliseconds

Solution 1: Aakash Kumar

You can use the

Timer.periodic(duration, callback)

It will repeat the task until cancelled


var timer = Timer.periodic(Duration(seconds: 1), (Timer t){
      //your code here

To cancel use