title: Repeating animations specific times e.g 20 times by Flutter
body: <blockquote>
    <p><strong>I have a simple animation :</strong></p>
  </blockquote>
  
  <pre><code>  Animation&lt;double&gt; animation;
    Tween&lt;double&gt; tween = Tween(begin: 1, end: 1.15);
    AnimationController animationController;
    @override
    void initState() {
      super.initState();
      animationController =
          AnimationController(vsync: this, duration: Duration(milliseconds: 300));
      animation = animationController.drive(tween);
  }
  
  </code></pre>
  
  <blockquote>
    <p><strong>What i want ?</strong></p>
  </blockquote>
  
  <p>make this animation repeats e.g 20 times  .</p>
  
  <blockquote>
    <p><strong>What i tried before posted this question ?</strong></p>
  </blockquote>
  
  <p>1- This method not have a parameter or way that makes me repeats this animation e.g 20 times.</p>
  
  <p><strong>it repeats and repeats and repeats forever :</strong>  </p>
  
  <pre><code>    animationController.repeat();
  
  </code></pre>
  
  <p>2- Use simple loops . It <strong>hangs</strong> my app, it <strong>requires to stop entire application and rerun it</strong> to solve that <strong>hanging</strong> . It's seems that <strong>loops completely not dealing with futures :</strong> </p>
  
  <pre><code>                            do {
                                animationController.forward().then((x) {
                                  animationController.reverse().then((x) {
                                    repeats++;
                                  });
                                });
                              } while (repeats &lt; 20);
  
  </code></pre>
  
  <p>3- Making int variable and add a listener ..etc,<strong>it's working</strong> , <strong>but</strong> seems that <strong>it's not the best way to do that matter :</strong> </p>
  
  <pre><code>  int repeats = 0;
  
      animation.addStatusListener((status) {
        if (repeats &lt; 20) {
          if (status == AnimationStatus.completed) {
            animationController.reverse();
          } else if (status == AnimationStatus.dismissed) {
            animationController.forward();
          }
          repeats++;
        }    });
  
  </code></pre>
  
  <p>4- make chain of then . **No comment on it **   :</p>
  
  <pre><code>    animationController.forward().then((x) {
        animationController.reverse().then((x) {
          animationController.forward().then((x) {
            animationController.reverse().then((x) {
              animationController.forward().then((x) {
                animationController.reverse();
              });
            });
          });
        });
      });
  
  </code></pre>
  
  <p>Now , shortly how can i repeat animation 20 times</p>