Home > Net >  Get params of callback function documented in Flutter (vscode)
Get params of callback function documented in Flutter (vscode)

Time:11-07

is there a way that vscode regognizes 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 archieve that I can reference to 'crazy' as well?

enter image description here

CodePudding user response:

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 { ... }
  • Related