lsp-dart icon indicating copy to clipboard operation
lsp-dart copied to clipboard

can not debug flutter app on Windows because of missing toolArgs

Open xhcoding opened this issue 3 years ago • 3 comments

When I debug flutter app with default flutter debug template, it's failed. By debug flutter with vscode , I found lsp-dart-dap missing toolArgs in launch args .

so I edit debug template, add toolArgs make dap-debug normally, like this:

(dap-register-debug-template
  "Flutter :: Debug"
  (list :name "Flutter :: Debug"
        :type "flutter"
        :toolArgs
        ["-d"
         "windows"
         "--dart-define=flutter.inspector.structuredErrors=true"
         "--web-allow-expose-url"
         "--devtools-server-address"
         "http://127.0.0.1:9100/"]))

Obviously, "windows" is the device id ,I hope it can be automatically populated through the debugging device I choose

xhcoding avatar Jan 21 '22 13:01 xhcoding

thanks for the report! @DanTup is toolArgs necessary for the debugger work?

ericdallo avatar Jan 21 '22 13:01 ericdallo

toolArgs should not be necessary, but if you want to specify a specific Device (rather than letting the Flutter tool decide which to use if there are multiple) you'll need to pass it.

As for the other flags here, I think structured errors are enabled by default so that flag shouldn't be required. --web-allow-expose-url is for web proxies when using web devices (so not required for Windows), and --devtools-server-address is for an IDE to pass an existing DevTools server to Flutter (so it doesn't start its own) so also not required here if your IDE is not spawning a server.

So the only thing you might really want is -d deviceId. In VS Code we use flutter daemon to monitor for devices and present them in a pick-list for the user, and pass the selected one when starting Flutter. Info about the device daemon is here:

https://github.com/flutter/flutter/blob/master/packages/flutter_tools/doc/daemon.md

DanTup avatar Jan 24 '22 10:01 DanTup

Thanks @DanTup we actually do the same on lsp-dart, I was just not sure if we should pass those args with a default or just don't pass at all if not user didn't overide

ericdallo avatar Jan 24 '22 13:01 ericdallo