Flutter run works from command line but not with VsCode - flutter

I installed Flutter and I have a project that used it (Flutter Web).
As IDE I use VsCode.
When I run the app using command line (flutter run --no-sound-null-safety) it works well, instead when I use VsCode I get this error:
ChromeProxyService: Failed to evaluate expression 'Future': InternalError: No frame with index 17.
ChromeProxyService: Failed to evaluate expression 'that': InternalError: No frame with index 17.
...
I launch the app with fn+f5 and I created this .vscode/launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "Web nosound null",
"type": "dart",
"request": "launch",
"deviceId": "chrome",
"args": [
"--no-sound-null-safety"
]
},
{
"name": "Web sound null",
"type": "dart",
"request": "launch",
"deviceId": "chrome",
"args": []
},
]
}
I tried also flutter clean but nothing changes, also uninstall and reinstall Flutter seems not to solve the problem.
VsCode is updated.
What am I wrong?

Related

Trouble getting Flutter to run in debug mode in VS Code

I am able to run my Flutter project in an emulator in Android Studio. I'm trying to run that same code in debug mode (f5) in VS Code, but I get an error saying:
Set the 'program' value in your launch config (eg 'lib/main.dart') then launch again.
So I updated my launch config to the following:
{
"version": "0.2.0",
"configurations": [
{
"name": "Dart & Flutter",
"request": "launch",
"type": "dart",
"program": "lib/main.dart"
}
]
}
After that update, when I try f5 I get the following error:
Your launch config references a program that does not exist. If you have problems launching, check the "program" field in your ".vscode/launch.json" file.
I DO have a main.dart file??
Any help would be greatly appreciated.
instead of "program": "lib/main.dart" try "flutterMode": "debug"
{
"version": "0.2.0",
"configurations": [
{
"name": "Dart & Flutter",
"request": "launch",
"type": "dart",
"flutterMode": "debug"
}
]
}
For some reason, VS Code was using the launch config from a different project folder that was in my workspace. After removing that project, f5 worked as expected.
flutter run would help, In my case first run flutter doctor , later do resolve missing configs as mentioned and then Flutter run

Run Flutter in both iOS and Web at the same time

I am trying to build and run a project in both iOS and Web from VS Code. Is there any way to do this?
I have tried running flutter run -d all but that only runs iOS, even though flutter devices lists both of them
Yep, you can create a compound launch config in your .vscode/launch.json. This one creates three configs, one to launch on the current device (shown in the status bar), one to launch on iOS, and one to launch on Android. It then creates a compound config that will launch on iOS and Android devices at the same time. You can change one of the device IDs to chrome to launch on Chrome.
{
"version": "0.2.0",
"configurations": [
{
"name": "Current Device",
"request": "launch",
"type": "dart"
},
{
"name": "Android",
"request": "launch",
"type": "dart",
"deviceId": "android"
},
{
"name": "iPhone",
"request": "launch",
"type": "dart",
"deviceId": "iphone"
},
],
"compounds": [
{
"name": "All Devices",
"configurations": ["Android", "iPhone"],
}
]
}
More info can be found on the Flutter wiki.

Problem debugging Deno using VSCode on Ubuntu 20.04 LTS running inside WSL-2: --inspect-brk being removed

I am trying to debug Deno using VSCode on Ubuntu 20.04 LTS running inside WSL-2. I setup my launch.json as described in the Deno manual:
{
"version": "0.2.0",
"configurations": [
{
"name": "Deno",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": ["run", "--inspect-brk", "-A", "${fileBasename}"],
"outputCapture": "std",
"port": 9229
}
]
}
however when I launch Deno the "--inspect-brk" option is being stripped out from the command used to launch Deno. If I modify my launch.json to change the option to "inspect-brk" (removing the leading --) the option shows up on the command line and I get the error:
Cannot resolve module "file:///mnt/c/Users/mlwp/projects/deno/inspect-brk"
Similarly if I change the name of the option to be "--inspect-brk-fun" then I get the message:
Found argument '--inspect-brk-fun' which wasn't expected, or isn't valid in this context
Anyone know why VSCode would strip the option or how to debug this
The cause of your issue was an incompatibility with --inspect-brk in previous versions of the VSCode JavaScript debugger. It has been fixed some time ago and so have the Deno docs on this matter, where the value of type has changed and port has been replaced with attachSimplePort in launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Deno",
"type": "pwa-node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": ["run", "--inspect-brk", "-A", "${file}"],
"attachSimplePort": 9229
}
]
}
However, I've found that using your current configuration should also work on newer releases (1.47+) of VSCode (running on Ubuntu 20.04 in WSL 2).

Debug mode does not activate breakpoint

I am trying to use debug mode in my react native application with visual studio code. I am using the command npx react-native run-android. It is activating the react native debugger, but it is not reaching any breakpoint in my application.
I did not find any tutorials to activate debug with npx, so could you guys show me one or explain me what is happening wrongly in this setup?
this is my launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug React Native",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "android",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
]
}
An interesting thing it is happening is once it is running the application if I click on the start debugging button my application restarts and it shows a message on debug console:
Launched debug configuration contains 'program' property which is deprecated and will be removed soon. Please replace it with: "cwd": "${workspaceFolder}"
Could not debug. The "path" argument must be of type string. Received type undefined
Since I have not received any answer, I took 3 days to discovered what was happening.
this is the correct configuration:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to packager",
//"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "attach",
"sourceMaps": true,
"cwd": "${workspaceFolder}",
//"outDir": "${workspaceRoot}/.vscode/.react"
},
]
}
Must run the command npx react-native run-android
Once the android emulator is running batch job must be stopped in the terminal
Go to the debug tab in vs code and run the application
ctrl + m on android emulator
click on debug option
Those were the baby steps that I did in order to have the application run in debug mode.

Debugging Node with Visual Studio Code (not powershell)

I'm trying to debug my node script that is running in Visual Studio Code. My first mistake (apparently) was I pressed the Debug menu choice. It launched the .net debugger (this is actually an asp.net core project) but I wanted to debug just the node server that I launched myself.
Now, when I bring up the terminal windows, the only choice seems to be type powershell (see red arrow).
What I want to do is debug my running node script that I started by typing "node start dev".
{
"version": "0.2.0",
"configurations":
[
{
"name": "node",
"type": "node",
"request": "launch",
"stopOnEntry": false,
"program": "${file}",
"cwd": "${workspaceFolder}",
"args": [
"start", "dev"
]
}
]}