title: How can I assign an argument of type 'Function' to a parameter of type 'void Function()'?
body: <p>I'm trying to create a stateless widget like this:</p>
  <pre class="lang-dart prettyprint-override"><code>import 'package:flutter/material.dart';
  
  class Answers extends StatelessWidget {
    final Function nextQuestion;
  
    Answers(this.nextQuestion);
  
    @override
    Widget build(BuildContext context) {
      return ElevatedButton(
        onPressed: nextQuestion,
        child: Text(&quot;Answer&quot;),    
      );
    }
  }
  </code></pre>
  <p>However, an error appears in the <code>onPressed</code> argument: &quot;The argument type 'Function' can't be assigned to the parameter type 'void Function()?'&quot;. How can I solve it?</p>