Search code examples
fluttervisual-studio-codecomments

Get params of callback function documented in Flutter (vscode)


Is there a way that vscode recognizes the params within its documentation when using Flutter?

As you can see the bool param 'important' can be referenced, 'crazy' param within function 'onCrazyThingsDone' can not.

Did I miss something?

How can I achieve that I can reference to 'crazy' as well?

enter image description here


Solution

  • Try this...

    Create an alias

    // Documentation for Crazy callback here
    typedef CrazyCallback = void Function(int crazy);
    

    Then use the alias in your function

    // Documentation for doCrazyThings method.
    Future<void> doCrazyThings({
        required bool important,
        CrazyCallback? onCrazyThingsDone,
    }) async { ... }