title: Tween animation flutter
body: <p>I want to play an animation when a button is clicked. On the first press, the widget rotates 180 degrees, on the second press, another 180 degrees (that is, it returns to its original position). How can I do this?</p>
  <p>Simulated gesture detector button</p>
  <pre><code>                      Expanded(
                          child: GestureDetector(
                            onTap: () =&gt; setState(() {
                              if (tapValue == 0) {
                                tapValue++;
                                animController.forward();
                                beginValue = 0.0;
                                endValue = 0.5;
                              } else {
                                tapValue--;
                                animController.forward();
                              }
                            }),
                            child: Container(
                              child: Image.asset('assets/images/enableAsset.png'),
                            ),
                          ),
                        ),
  </code></pre>
  <p>The widget I want to rotate</p>
  <pre><code>            child: CustomPaint (
                painter: SmileyPainter(),
                child: RotationTransition(
                  turns: Tween(begin: beginValue, end: endValue,).animate(animController),
                  child: CustomPaint (
                    painter: Smile(),
                  ),
                ),
              )
  </code></pre>
  <p>animation controller</p>
  <pre><code>  @override
    void initState() {
      animController = AnimationController(
        duration: const Duration(milliseconds: 400),
        vsync: this,
      );
      super.initState();
    }
  </code></pre>