title: How to reach a variable of a class from another class in Flutter
body: <p>I have a stateful widget which includes buttons. I'm keeping number of user taps in an int variable called "counter".</p>
  
  <p>I have another widget which is my home screen. I have a Text on that screen. I need to show the number of taps on this Text dynamically. So when user taps the button on the first class, my Text on the second class must be updated.</p>
  
  <p>What is the best way to pass the counter variable from first widget to second widget?</p>
  
  <p><strong>Added some code</strong></p>
  
  <p>Both of my classes are stateful widgets. So, I declared static int counter like these;</p>
  
  <pre><code>class AppListView extends StatefulWidget {
    static int counter;
  
    @override
    _AppListViewState createState() =&gt; _AppListViewState();
  }
  </code></pre>
  
  <p>Now I can reach counter from other class but can't reach from its own class. I mean I need to increase counter in that part but It says undefined.</p>
  
  <pre><code>class _AppListViewState extends State&lt;AppListView&gt; {
  @override
    Widget build(BuildContext context) {
      return FlatButton(
             onPressed: (){
                counter++ (can't reach counter here)
        }
  </code></pre>