title: I want to call a method present in a stateful class from another stateful class in flutter
body: <p>There are two stateful widgets, I want to call a method present in one class from another onTap. Below is the brief code:</p>
  <pre><code>
  class FirstClass extends StatefulWidget {
    final String total;
    FirstClass(this.total);
    @override
    _FirstClassState createState() =&gt; _FirstClassState();
  }
  class _FirstClassStateState extends State&lt;FirstClassState&gt; {
  
  Model getModel(abc){ //Model class is in another dart file
  Model nModel = new Model();
  nModel.n1 = abc;
  
  }
  next(){
  setstate(){some code}
  }
  SecondClass (
  model: getModel(s),
  num:1,
  )
  }
  class SecondClass extends StatefulWidget {
    final Model model;
    final int num;
   SecondClass({@required this.model, @required this.num});
    @override
    _SecondClassState createState() =&gt; _SecondClassState();
  }
  class _SecondClassState extends State&lt;SecondClass&gt; {
  onTap(){ //I have to call the method next() from here }
  }
  ========================================================================
  </code></pre>
  <p>Yes,the SecondClass is present inside widget tree of FirstClass</p>