1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Flutter Exited (-30) using Neovim + DAP

Discussão em 'Mobile' iniciado por Stack, Outubro 4, 2024 às 05:12.

  1. Stack

    Stack Membro Participativo

    I have been trying to use Flutter with nvim, but I keep on running into this issue.
    I am using flutter-tools.nvim. I also use fvm ( thought this might be importnat ).
    The issue is when enabling the debugger, the program crashes after the first file save with Exit Code (-30).

    flutter doctor -v

    [✓] Flutter (Channel stable, 3.24.3, on macOS 15.0 24A335 darwin-arm64, locale en-QA)
    • Flutter version 3.24.3 on channel stable at /Users/aghazaly/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (3 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/aghazaly/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

    [✓] Xcode - develop for iOS and macOS (Xcode 16.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16A242d
    • CocoaPods version 1.15.2

    [✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

    [✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
    https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
    https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

    [✓] VS Code (version 1.93.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.98.0```


    I tried looking at others setups to find if something is out of the ordinary in mine, but didn't find anything that could be the cause.

    Here is my flutter-tools.nvim config

    return {
    'akinsho/flutter-tools.nvim',
    lazy = false,
    dependencies = {
    'nvim-lua/plenary.nvim',
    'stevearc/dressing.nvim', -- optional for vim.ui.select
    'mfussenegger/nvim-dap',
    },
    config = function()
    local api = vim.api

    -- Add the toggle log function
    local function toggle_log()
    local wins = api.nvim_list_wins()

    for _, id in pairs(wins) do
    local bufnr = api.nvim_win_get_buf(id)
    if api.nvim_buf_get_name(bufnr):match '.*/([^/]+)$' == '__FLUTTER_DEV_LOG__' then
    return vim.api.nvim_win_close(id, true)
    end
    end

    pcall(function()
    vim.api.nvim_command 'split + __FLUTTER_DEV_LOG__ | resize 15'
    end)
    end

    -- Set up the keymap for toggling the Flutter dev log
    vim.keymap.set("n", "<leader>fl", toggle_log, { desc = "Toggle Flutter dev log" })

    -- require("telescope").load_extension("flutter")
    require("flutter-tools").setup {
    ui = {
    border = "rounded",
    notification_style = 'native',
    },
    decorations = {
    statusline = {
    app_version = false,
    device = true,
    project_config = true,
    }
    },
    debugger = {
    enabled = true,
    run_via_dap = true,
    exception_breakpoints = {},
    evaluate_to_string_in_debug_views = true,
    register_configurations = function(paths)
    local dap = require("dap")
    dap.adapters.dart = {
    type = "executable",
    command = paths.flutter_bin,
    args = { "debug-adapter" },
    }
    dap.configurations.dart = {}
    require("dap.ext.vscode").load_launchjs()
    end,
    },
    root_patterns = { ".git", "pubspec.yaml" },
    fvm = true,
    widget_guides = {
    enabled = true,
    },
    closing_tags = {
    enabled = true,
    highlight = 'LineNr',
    prefix = '// ',
    priority = 0,
    },
    dev_log = {
    enabled = true,
    filter = nil,
    notify_errors = false,
    open_cmd = "15split",
    },
    dev_tools = {
    autostart = false,
    auto_open_browser = false,
    },
    outline = {
    open_cmd = "30vnew",
    auto_open = false
    },
    lsp = {
    color = { -- show the derived colours for dart variables
    enabled = false, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10
    background = false, -- highlight the background
    background_color = nil, -- required, when background is transparent (i.e. background_color = { r = 19, g = 17, b = 24},)
    foreground = false, -- highlight the foreground
    virtual_text = true, -- show the highlight using virtual text
    virtual_text_str = "■", -- the virtual text character to highlight
    },
    init_options = {
    onlyAnalyzeProjectsWithOpenFiles = false,
    suggestFromUnimportedLibraries = true,
    closingLabels = true,
    outline = false,
    flutterOutline = false,
    },
    -- see the link below for details on each option:
    -- https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/tool/lsp_spec/README.md#client-workspace-configuration
    settings = {
    showTodos = true,
    completeFunctionCalls = true,
    analysisExcludedFolders = {
    "$HOME/AppData/Local/Pub/Cache",
    "$HOME/.pub-cache",
    "/opt/homebrew/",
    "$HOME/tools/flutter/",
    },
    renameFilesWithClasses = "prompt",
    enableSnippets = true,
    updateImportsOnRename = true,
    }
    }
    --
    }
    end,
    }


    I tried first without any nvim-dap config, and got this error.
    After adding the dap config, I still get the same error.

    Here is the dap config:

    return {
    {
    "rcarriga/nvim-dap-ui",
    dependencies = {
    "mfussenegger/nvim-dap",
    "nvim-neotest/nvim-nio"
    }
    },
    {
    "mfussenegger/nvim-dap",
    dependencies = {
    'nvim-neotest/nvim-nio',
    'rcarriga/nvim-dap-ui',
    },
    event = 'VeryLazy',
    config = function()
    local dap = require('dap')

    dap.configurations.dart = {
    {
    type = "dart",
    request = "launch",
    name = "Launch dart",
    dartSdkPath = "$HOME/fvm/default/bin/flutter",
    flutterSdkPath = "$HOME/fvm/default/bin/flutter",
    program = "${workspaceFolder}/lib/main.dart", -- ensure this is correct
    cwd = "${workspaceFolder}",
    },
    {
    type = "flutter",
    request = "launch",
    name = "Launch flutter",
    dartSdkPath = "$HOME/fvm/default/bin/flutter",
    flutterSdkPath = "$HOME/fvm/default/bin/flutter",
    program = "${workspaceFolder}/lib/main.dart", -- ensure this is correct
    cwd = "${workspaceFolder}",
    }
    }
    require("dapui").setup({
    icons = { expanded = "▾", collapsed = "▸" },
    layouts = {
    {
    elements = {
    { id = "scopes", size = 0.25 },
    "breakpoints",
    "stacks",
    "watches",
    },
    size = 10, -- columns
    position = "bottom",
    },
    },
    })
    end
    }
    }

    Continue reading...

Compartilhe esta Página