title: How to access to a method in a statefull widget?
body: <p>I want to access this method <code>updateCounter()</code> from another class. How should I call it? Or how can I instantiate <code>_HomePageState</code>?</p>
  
  <p>Here is my code :</p>
  
  <pre><code>class HomePage extends StatefulWidget {
    @override
    _HomePageState createState() =&gt; _HomePageState();
  }
  
  class _HomePageState extends State&lt;HomePage&gt; {
     static int i=0;
     void updateCounter(int counter) {
      print(counter);
      setState(() {
        i=counter;  
      });
    }
  
    @override
    Widget build(BuildContext context) {
      return Container(
  
      );
    }
  }
  </code></pre>