title: Flutter trigger a function inside a widget from the father
body: <p>Let said I have a widget &quot;mySonWidget&quot; inside this widget I have a function &quot;updateIconColor&quot;, I want to call that function from the father of &quot;mySonWidget&quot;</p>
  <p>I did something similiar with callback but this is not the same scenario.
  I saw people other widgets doing similar thing with controllers, but I don't know how create a custom controller.</p>
  <p>How can I do it?
  HELP</p>
  <pre><code>class mySonWidget extends StatefulWidget {
    @override
    _mySonWidgetState createState() =&gt; _mySonWidgetState();
  }
  
  class _mySonWidgetState extends State&lt;mySonWidget&gt; {
    var _iconColor = Colors.red[500];
  
    void updateIconColor() {
      setState(() {
        print('updateIconColor was called');
        _iconColor = Colors.green;
      });
    }
  
    @override
    Widget build(BuildContext context) {
      return Container(
        padding: EdgeInsets.all(0),
        child: IconButton(
          icon: (Icon(Icons.star)),
          color: _iconColor,
          onPressed: () {},
        ),
      );
    }
  }
  </code></pre>
  <p>father example:</p>
  <pre><code>class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
        debugShowCheckedModeBanner: false,
        home: Scaffold(
          body: Column(children: &lt;Widget&gt;[
            mySonWidget(),
            FlatButton(
              onPressed: () {
                /*..Call Function inside mySonWidget (updateIconColor) ..*/
              },
              child: Text(
                &quot;Change Color&quot;,
              ),
            ),
          ]),
        ),
      );
    }
  }
  </code></pre>