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

新手配置Neovim Flutter调试器遇报错:flutter/bin/dart.bat退出码64

解决Neovim Flutter调试器报错 dart.bat exited with code: 64

问题诊断

你的配置里有两处关键错误导致调试器启动失败:

  1. flutter_path 配置错误
    你把flutter_path指向了dart.bat,但这个参数需要的是Flutter可执行文件路径,而非Dart的可执行文件。

  2. Dart Debug Adapter路径拼接错误
    vim.fn.stdpath("data")返回的是Neovim的数据目录(例如C:/users/user/AppData/Local/nvim-data),你直接将绝对路径拼在其后,会生成无效路径(如C:/xxx/nvim-dataC:/users/user/...),导致无法找到调试适配器。

修正后的配置

require("flutter-tools").setup {
    flutter_path = 'C:/flutter/flutter/bin/flutter.bat', -- 改为flutter可执行文件路径
    ui = {border = "rounded", notification_style = "plugin"},
    outline = {open_cmd = "30vnew", auto_open = false},
    closing_tags = {
        highlight = "Comment",
        prefix = "// ",
        enabled = true
    },
    debugger = {
        enabled = true,
        run_via_dap = true,
        register_configurations = function(_)
            require('dap.ext.vscode').load_launchjs(nil, {})
            -- 修复路径拼接逻辑,生成正确的调试适配器路径
            require("dap").adapters.dart = {
                type = "executable",
                command = vim.fn.stdpath("data") .. "/mason/bin/dart-debug-adapter.cmd",
                args = {"dart"}
            }
        end
    },
    dev_log = {enabled = false, open_cmd = "tabedit"},
    lsp = {
        color = {
            enabled = true,
            background = false,
            background_color = {r = 220, g = 223, b = 228},
            foreground = false,
            virtual_text = true,
            virtual_text_str = "■"
        },
        settings = {
            showTodos = true,
            completeFunctionCalls = true,
            renameFilesWithClasses = "prompt",
            enableSnippets = true,
            enableSdkFormatter = true,
            analysisExcludedFolders = {".dart_tool"}
        }
    }
}

额外检查步骤

  • 确认已通过Mason安装dart-debug-adapter,可通过:Mason命令查看安装状态。
  • 若使用launch.json,确保配置指向正确的项目入口文件,示例如下:
    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Flutter",
                "request": "launch",
                "type": "dart",
                "program": "lib/main.dart"
            }
        ]
    }
    
  • 重启Neovim后再尝试执行dap.continue()。

内容的提问来源于stack exchange,提问作者Hercule Poirot

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 07:55:55