You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS Code中Dart函数补全无括号问题求助及解决办法

VS Code中Dart函数补全不带括号的问题解决

在VS Code中编写Dart函数或方法(例如print)时,弹出函数列表后按下Enter,补全的函数不带括号,严重拖慢开发效率。

我的settings.json配置如下:

{
  "files.autoSave": "afterDelay",
  "files.autoSaveDelay": 3000,
  "editor.fontSize": 18,
  "editor.fontFamily": "JetBrains Mono, Fira Code, monospace",
  "editor.fontWeight": "400",
  "editor.fontLigatures": true,
  "editor.wordWrap": "on",
  "git.ignoreWindowsGit27Warning": true,
  "editor.formatOnSave": true,
  "prettier.jsxSingleQuote": true,
  "prettier.singleQuote": true,
  "workbench.colorTheme": "One Dark Pro Darker",
  "emmet.includeLanguages": {
    "javascript": "javascriptreact",
    "typescript": "typescriptreact"
  },
  "[html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
  },
  "[prisma]": {
    "editor.defaultFormatter": "Prisma.prisma"
  },
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[json]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "editor.formatOnPaste": true,
  "workbench.iconTheme": "material-icon-theme",
  "javascript.preferences.quoteStyle": "single",
  "typescript.preferences.quoteStyle": "single",
  "editor.tabSize": 2,
  "editor.detectIndentation": false,
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescriptreact",
    "typescript"
  ],
  "editor.smoothScrolling": true,
  "security.workspace.trust.enabled": false,
  "files.defaultLanguage": "plaintext",
  "workbench.startupEditor": "newUntitledFile",
  "editor.renderControlCharacters": true,
  "terminal.integrated.defaultProfile.windows": "Git Bash",
  "terminal.integrated.profiles.windows": {
    "Ubuntu (WSL)": {
      "path": ["C:\\WINDOWS\\System32\\wsl.exe"],
      "icon": "terminal-ubuntu"
    }
  },
  "editor.linkedEditing": true,
  "editor.parameterHints.enabled": false,
  "editor.hover.enabled": true,
  "launch": {
    "configurations": []
  },
  "editor.snippetSuggestions": "bottom",
  "editor.cursorBlinking": "expand",
  "explorer.compactFolders": false,
  "prettier.arrowParens": "avoid",
  "diffEditor.ignoreTrimWhitespace": false,
  "html.completion.attributeDefaultValue": "singlequotes",
  "javascript.updateImportsOnFileMove.enabled": "always",
  "typescript.updateImportsOnFileMove.enabled": "always",
  "cSpell.language": "en, ru",
  "auto-close-tag.disableOnLanguage": ["javascriptreact", "typescriptreact"],
  "terminal.integrated.fontFamily": "Fira Code, monospace",
  "terminal.integrated.fontSize": 16,
  "editor.autoClosingBrackets": "always",
  "editor.codeActionsOnSave": {
    "quickfix.insertSemicolon": true
  },
  "window.commandCenter": true,
  "prettier.trailingComma": "none",
  "dart.lineLength": 500,  // comment out this line
  "[dart]": {
    "editor.defaultFormatter": "Dart-Code.dart-code",
    "editor.formatOnSave": true,
    "editor.formatOnType": true,
    "editor.rulers": [500],
    "editor.selectionHighlight": false,
    "editor.suggest.snippetsPreventQuickSuggestions": false,
    "editor.suggestSelection": "first",
    "editor.tabCompletion": "onlySnippets",
    "editor.wordBasedSuggestions": false,
    "editor.wordWrapColumn": 100000
  },
  "dart.previewFlutterUiGuides": true,
  "dart.previewCommitCharacters": true,
  "dart.previewHotReloadOnSaveWatcher": true,
  "dart.completeFunctionCalls": true,
  "dart.enableCompletionCommitCharacters": false,
  "[python]": {
    "editor.formatOnType": true
  },
  "javascript.suggest.completeFunctionCalls": true,
  "typescript.suggest.completeFunctionCalls": true
}

曾尝试添加以下配置到settings.json,但未解决问题:

"dart.completeFunctionCalls": true,
"dart.enableCompletionCommitCharacters": false,

解决方案

最终通过为Dart创建新的配置文件,并删除所有VS Code扩展的方式解决了该问题。


内容的提问来源于stack exchange,提问作者Сергей Манжак

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 03:57:06