title: How to access Stateful widget animation controller from another widget in Flutter?
body: <p>I want the counter widget to show <code>onTap</code> from home <code>widget</code>. Also, start the <code>animation</code> from start at every tap.</p>
  
  <p><strong>Counter Widget</strong></p>
  
  <pre><code>class Counter extends StatefulWidget {
    @override
    _CounterState createState() =&gt; _CounterState();
  }
  
  class _CounterState extends State&lt;Counter&gt; with SingleTickerProviderStateMixin {
    AnimationController animationController;
    Animation&lt;double&gt; animation;
  
    @override
    void initState() {
      super.initState();
      animationController = AnimationController(
        vsync: this,
        duration: Duration(milliseconds: 1000),
      )
        ..addListener(() =&gt; setState(() {}));
  
      animation = CurvedAnimation(
        parent: animationController,
        curve: Curves.elasticOut,
      );
  
      animationController.forward();
    }
  
    @override
    Widget build(BuildContext context) {
      return ScaleTransition(
        child: Container(
          height: 100,
          width: 100,
          color: Colors.blue,
        ),
        scale: animation,
      );
    }
  }
  </code></pre>
  
  <p><strong>Home Widget</strong></p>
  
  <pre><code>  @override
    Widget build(BuildContext context) {
      return Scaffold(
          body: Stack(
        children: &lt;Widget&gt;[
          Center(
            child: Counter(),
          ),
          GestureDetector(
            onTap: () {},
            child: Container(
              width: double.infinity,
              height: double.infinity,
            ),
          ),
        ],
      ));
    }
  </code></pre>