Sdk: When completing a named function argument, can we include the boilerplate for the function signature?

Created on 15 Dec 2015  路  7Comments  路  Source: dart-lang/sdk

I'm trying to setup a FlatButton. I know it takes something like onPressed. I write new FlatButton() and then code complete inside the parens. I scroll to find onPressed (yay!) and hit enter.

Expected: add onPressed: () { }

Actual: onPressed:

That is, please fill in the function signature (which, in this case, is VoidCallback) when completing a named parameter that is a function.

I tried to code complete after the : but all I found was:

screen shot 2015-12-15 at 2 05 56 pm

I had to go to the docs to find out what onPressed expected. I was hoping I could learn that through code completion.

P2 analyzer-completion area-analyzer customer-flutter type-bug

All 7 comments

Another example that I just ran into:

new List.genCODE COMPLETE HERE

Actual: new List.generate(length, generator)

Hoped/expected: new List.generate(length, (int index) => null)

If we do this at all, we should provide both options for completion:

onPressed: () => null
onPressed:

I hate having to select text that was added for me and remove / replace it when it's wrong, and I often want to pass in a tear-off in cases like these. If we do this then we ought to also allow completion (to something like () => null) after the colon.

Of course, if we complete named parameter values we also need to complete positional parameter values that way.

After autocomplete to "onPressed:", if you type "(" perhaps it should autocomplete to the parameter list for the callback function?

Lambda completion is implemented w/ e0c178b.

This is awesome to see! Is there a reason why this functionality is limited to named arguments, and not positional arguments, though?

I would love to see this for functions like Iterable.map/.where that take a single function argument.

@greglittlefield-wf: working on it, but I see it wasn't tracked. Added here: https://github.com/dart-lang/sdk/issues/40202.

Thanks for the feedback!

Awesome, I'm so excited!! :smiley: Thanks for the update!

Was this page helpful?
0 / 5 - 0 ratings