title: Pass method as parameter to a widget
body: <p>I have a custom button widget:</p>
  <pre><code>class Button extends StatelessWidget {
    final String text;
  
    Button(this.text);
  
    @override
    Widget build(BuildContext context) {
      return Container(
        height: 50,
        child: SizedBox(
          width: double.infinity,
          child: RaisedButton(
            onPressed: () =&gt; {}, // Use the function from parent Widget
            child: Padding(
                padding: EdgeInsets.symmetric(vertical: 13),
                child: Text(
                  text,
                  style: TextStyle(fontWeight: FontWeight.bold),
                )),
            color: COLOR_BLUE,
            textColor: Colors.white,
            shape:
                RoundedRectangleBorder(borderRadius: BorderRadius.circular(25)),
          ),
        ),
      );
    }
  }
  </code></pre>
  <p>Then in parent Widget I want to pass a <code>onPressed</code> method to this button widget:</p>
  <pre><code>...
  myMethod () =&gt; {
     // do some stuff
  }
  ...
  Padding(
      padding: EdgeInsets.only(bottom: 10),
      child: Button(&quot;Log in&quot;, myMethod),
  ),
  ...
  </code></pre>
  <p>How can I tell a button widget to use the <code>myMethod</code> for <code>onPress</code>?</p>