-
-
Notifications
You must be signed in to change notification settings - Fork 35
DAP support dart
Zeioth edited this page Aug 26, 2023
·
4 revisions
Nothing special needs to be done for Dart/Flutter.
Please note that this section has nothing to do with compiler.nvim. I'm documenting this to make your life easier. To debug Dart/Flutter with DAP you have to:
- Install the mason package
dart-debug-adapter
. -
:cd
your project root before running DAP. - Note that on dart projects, your program code is in
./lib
, a dir above that you have the project root.
Here you have an example of how to configure DAP for Dart/Flutter
local dap = require("dap")
-- Dart / Flutter
dap.adapters.dart = {
type = 'executable',
command = vim.fn.stdpath('data')..'/mason/bin/dart-debug-adapter',
args = {'dart'}
}
dap.adapters.flutter = {
type = 'executable',
command = vim.fn.stdpath('data')..'/mason/bin/dart-debug-adapter',
args = {'flutter'}
}
dap.configurations.dart = {
{
type = "dart",
request = "launch",
name = "Launch dart",
dartSdkPath = "/opt/flutter/bin/cache/dart-sdk/", -- ensure this is correct
flutterSdkPath = "/opt/flutter", -- ensure this is correct
program = "${workspaceFolder}/lib/main.dart", -- ensure this is correct
cwd = "${workspaceFolder}",
},
{
type = "flutter",
request = "launch",
name = "Launch flutter",
dartSdkPath = "/opt/flutter/bin/cache/dart-sdk/", -- ensure this is correct
flutterSdkPath = "/opt/flutter", -- ensure this is correct
program = "${workspaceFolder}/lib/main.dart", -- ensure this is correct
cwd = "${workspaceFolder}",
}
}
Just insert a breakpoint, run :DapContinue
and you will see something like
Example of debugging dart Example of debugging flutter
Congratulations, now you can compile and debug Dart/Flutter.
- You don't need to manually compile the program in debug mode before calling
DAP
. The debug adapter takes care of everything. - If you find any issue while configuring DAP, run
:DapSetLogLevel trace
and:DapShowLog
to find the reason.