Dart Code 3.2.1
Mac OS
Hi, when I use quick fix on a function that doesn't have it's parentheses (or arguments, ie I'm specifying the function type rather making a call to a function), quick fix doesn't suggest the function import statement for me. When the parentheses are added quick fix suggests the import.
Sometimes I pass functions around so the quick fix without the parentheses would be really useful.
doStuff(anotherFunction); // quick fix doesn't work
doStuff(anotherFunction()); // quick fix works
Would it be possible for the quick fix to work on the function without the parentheses?
Thank you
@bwilkerson @scheglov do you know if there's a reason the import quickfix doesn't appear here, or is it just an oversight and could be added?
@twistedinferno another quick way to import in the meantime is using the code completion - it should list functions even if they're not imported and automatically import them when selected. You can invoke completion with Cmd+Space/Ctrl+Space even if you've typed the full function name and it'll add the import:

It will also add parens on the end though unless you disable dart.insertArgumentPlaceholders, so it may be just as annoying depending on whether you're happy to disable that or not.
Thanks Danny, for some reason the code completion doesn't always suggest the function (I'm unsure why or in which situations but I will keep an eye out, maybe I wasn't always using the correct shortcut though). When it doesn't suggest it I put the parens at the end just so I can get the import so I have a work around.
Yes. Those two diagnostics have different codes associated with them, and the code for the top line doesn't have that fix associated with it. We should be able to fix that, but I can't give you a timeline for such a fix.
for some reason the code completion doesn't always suggest the function
If you've only recently opened the project, there might be a delay before the completions for unimported symbols show up - but if you're not seeing them at all even after a while, it's worth opening another issue for.
Yes. Those two diagnostics have different codes associated with them
Aha - one is undefined_function and the other undefined_identifier. I don't mind taking a look - I'm not very familiar with how the fixes work so it's an opportunity to look through them even if it's relatively straight forward.
Fix is in https://github.com/dart-lang/sdk/commit/3011ca2da76d3dd0a6abed74750fe93d95bae17b. It may take a little time to make it to a Dart (or Flutter) stable release though.
for some reason the code completion doesn't always suggest the function
...the reason why it didn't always suggest the import is because one small project was in my workspace but not referenced in my .yaml file! (I think it just gave me the impression that it was included because the folder was in my Workspace...silly mistake by me but just in case someone else has the same problem! (a 'nice to have' feature request could be a suggestion to import the reference into the .yaml file; perhaps if it belongs in the Workspace but not in the .yaml?)
I'm confused - if the project wasn't referenced, wouldn't it not show up either with or without parens?
a 'nice to have' feature request could be a suggestion to import the reference into the .yaml file; perhaps if it belongs in the Workspace but not in the .yaml?
That does sound like it could be useful, but would also need implementing in the server so maybe worth opening an issue in the SDK repo. I don't think the server currently manipulates the pubspec though so I'm not sure how involved it'd be (or how common multi-project workspaces are).
Most helpful comment
Fix is in https://github.com/dart-lang/sdk/commit/3011ca2da76d3dd0a6abed74750fe93d95bae17b. It may take a little time to make it to a Dart (or Flutter) stable release though.