title: Flutter calling child class function from parent class
body: <p><strong>Code</strong>:</p>
  
  <pre><code>class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        home: Scaffold(
          appBar: AppBar(
            leading: IconButton(
              icon: Icon(Icons.help),
              onPressed: () {
                // how can I call methodA from here?
              },
            ),
          ),
          body: HomePage(),
        ),
      );
    }
  }
  
  class HomePage extends StatefulWidget {
    @override
    _HomePageState createState() =&gt; _HomePageState();
  }
  
  class _HomePageState extends State&lt;HomePage&gt; {
    @override
    Widget build(BuildContext context) {
      return Container();
    }
  
    void methodA() {}
  }
  </code></pre>
  
  <p><strong>Question</strong>:
  I want to call <code>methodA()</code> from <code>onPressed()</code> of <code>IconButton</code>. How can I do that, I know how to call parent's method from child class but this use case is different.  </p>