title: How can I define a data type VoidCallback or AsyncCallback in Flutter?
body: <p>When creating a widget, I want to receive a function type parameter.</p>
  <p>However, the type of this parameter can be VoidCallback or AsyncCallback.</p>
  <p>Is there a way to apply these two types together? It is now declared dynamic.</p>
  <p>This my code, see <code>onPress</code> field:</p>
  <pre><code>class MyWidget extends StatelessWidget {
    final dynamic onPress;
    final String text;
    final Color? textColor;
    const MyWidget ({Key? key, required this.onPress, required this.text, this.textColor}) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return Container(
        margin: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
        child: TextButton(
          onPressed: onPress,
          child: Text(text, style: TextStyle(color: textColor ?? Colors.black),
          ),
        ),
      );
    }
  }
  </code></pre>