Answer a question

I have a question. Is it possible to change Flutter's AutoComplete order in VS code?

If I try to put an IconButton, IconButton Snippet is recommended, and autocomplete is as follows.

for example

IconButton(onPressed: onPressed, icon: icon),

But I want the order to be like this.

IconButton(icon: icon, onPressed: onPressed),

How can I change this?

Answers

If you have not typed any prefix and are seeing the "full list" of code completion, then the ordering is determined by the Dart analysis server. They should be sorted with "relevant" items at the top (where "relevant" is a computed score that takes into account a number of things).

However, if you have typed any characters (such as "icon") so that the list has been filtered, then VS Code is handling the ranking. VS Code's ranking is based only on the text of the completion and the text you've typed and does not have any additional context (such as which types are most likely there), which can sometimes result in sub-optimal ranking.

It's not clear which of these is the case here, but a screenshot would help understand.

There are some related issues in the VS Code issue tracker relating to the second point above:

  • https://github.com/microsoft/vscode/issues/79516 - a report of VS Code ignoring server-provided ranking - considered by design
  • https://github.com/microsoft/vscode/issues/127516 - a feature request for a way for VS Code to use type information to provide better completions/ranking
Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐