Run Dart Console Application In Terminal with Visual Studio Code - flutter

I am trying to create a Dart console application that runs in the terminal rather than the Debug Console in Visual Studio Code.
Currently, when I press the play button:
It runs in the Debug Console. The problem with that is that the Debug Console cannot get user input from the line:
String userInput = stdin.readLineSync();
I know I can run the dart file from the terminal with:
dart C:\Applications\Dart\hello_world\bin\hello_world.dart
But I would prefer to use the play button out of convenience.
I found that you can edit the launch.json file to specify where it should run but it is not working. Even with the change shown in the picture below, it still runs in the debug console. In the picture you will notice a warning regarding how it only works with version from v2.7.1
I guess I was optimistic that the line "only supported for Dart SDKs from v2.7.1" was implying "SDKs from v2.7.1 and up.". However, it mostly likely means that version of the Dart SDK only.
Any help in achieving the goal of running a Dart file in the terminal using the Run button would be greatly appreciated.
If this is not possible, why would they take that functionality out of the newer Dart SDK's?

Your launch.json file is Ok, just check the file name. The main problem is that you use the debug button from the upper-right corner of the editor, but this button does not accept settings from launch.json.
You should use debug panel on the left side, as shown in the screenshot:
Make sure configuration's name (to the right of the green arrow) matches one from launch.json.

Related

need help in VSCODE debug

I'm a VSCODE first-time user. I tried to run debug on a simple python file and was not successful. I got 2 strange results:
the debug tool bar showed and disappeared instantly
no local variables was shown in VARIABLE section
Please see the screenshot.
Anyone could give me a hint anything was missing in what I did?
You need the python vscode extension to debug a python file. When you press F5 to start debugging, a menu will ask you what you are trying to debug. Click on Python File. The python extension creates a launch.json file for you and starts the debugger.
I noticed the Run and Debug tab is in your screenshot. Click that tab above where the variables would be shown and it should ask you to create the launch.json file in order to debug the file.
Read more on debugging and launch configurations for python here: https://code.visualstudio.com/docs/python/debugging

After updating Dart its showing "Configuration ' (Flutter)' is missing in 'launch.json'."

I opened vs code and it said "Your Dart Code is Updated" to version 3.something; but after that I can't run my app it gives me error
Configuration 'NameOfApp (Flutter)' is missing in 'launch.json'.
What should i do
Goto Run in vscode then click on Add Configuration option. Thats all now you can run your app without any problem.
Check the indenting of the code inside lunch.json.
Sometimes if you copy/paste the launch.json file from another project or source you might have an extra column that breaks vs code debug process. At least that was my case!
Open VS Code>Run>Add Configuration.
now run your app! It must works fine.

Issue with VSC build (CMD-Shift-B) command on mac

I am working through the instructions on building VSC for developers (https://github.com/Microsoft/vscode/wiki/How-to-Contribute#build-and-run) currently. Right under "Build" it instructs me to go "Go into vscode and start the build task with CMD+Shift+B) since I have a mac. I have gone into the folder in my finder and have pressed this combination of buttons but nothing happens at all. Am I supposed to do this in the terminal or am I missing anything?
It looks like the vscode directory must be opened in Visual Studio Code and a build is performed with ⌘ Command+Shift+B.
Here is an older version of the instructions where it is clearer:
https://github.com/microsoft/vscode-wiki/blob/2e2d6b0/How-to-Contribute.md#build
It appears that the directory vscode got mixed up with the full application name in a subsequent edit.

VS Code and Flutter/Dart, Widget Autocomplete not working

I'm working with some tutorials to learn Flutter and the one that I'm taking now uses VSCode. I actually prefer it to Android Studio because it doesn't overheat my Macbook. The only frustration I've had with it so far is that there are quite a few times where autocomplete just stops working. For instance, if I wrap a Column in a widget and then start typing Container, Android Studio will pop up an autocomplete showing Container VS Code used to do this for me, but has stopped for some reason. I can still get the autocomplete list if I press Ctrl+Spacebar.
I'm using the following:
VS Code - 1.36.1
Dart Extension - 3.2.0
Flutter Extension - 3.2.0
Material Icon Theme - 3.8.0
This is the latest version for all of these.
Is there some setting or something that I need to change? I've spent the last two hours trying to work out what's going on. In searching, I did see some references to earlier versions of VS Code and the extensions causing problems, but nothing about these versions.
Go to pubspec.yaml and hit save or run get packages. It worked for me, hope it helps
There are generally two reasons for VS Code to automatically open code completion - 1) when you press a key that the extension ahs told VS Code should invoke it and 2) when VS Code thinks it would be useful (for example when you start typing on a blank line). If you're typing in a line of existing code it won't always do this.
Pressing Ctrl+Space is the correct way to open completion in the cases where it doesn't appear automatically.
That said, if you can provide more information about a specific instance, I can take a look if it's something we could/should pop completion open for. It would be best raised at https://github.com/Dart-Code/Dart-Code/issues with a screenshot and details of exactly where your cursor is (and how you got there).
dont use too many flutter extension, I also face this problem , then I realize that 3 flutter extension are installed, use only one , it works for me, try it.
I did have a derivative of this problem when I was working with VS Code and flutter and this is what I did.
This is for windows though. This is what I did ;
Go to C:\Users<your username >\AppData\Roaming\Code and delete all the files and the directory called "Code". Usually the folder AppData is hidden so you'll have to unhide it. Then restart your computer and then reopen VS Code. This I think cleared some of the unwanted cache files which kind of made things right again.
Hope it helped.
Make sure
Preferences > Editor > Intentions > Quick assist powered by the Dart
Analysis Server
is enabled (Screenshot).
If so, most likely your Dart Analysis server is crashing. Navigate to your HOME folder:
cd ~
And then below should resolve your issue:
sudo chown -R $USER .dart .flutter
Clear your cache if the issue still exists:
File > Invalidate Caches > Clear file system cache and Local History > Invalidate and Restart.
Also, Power Save Mode should be disabled:
File > Power Save Mode
Doing a flutter clean and then flutter pub upgrade worked for me. Sometimes flutter clean using the command line does not work if you have android studio then in tools go to flutter and then do flutter clean.
just do flutter clean then flutter create. and then flutter pub upgrade, and also see if your flutter SDK is latest or not.
Check to make sure Android Studio is not on low power mode
Menu>File>Low Power Save Mode
I solved in in my Macbook Pro by
Going to System Preferences > Keyboard > Shortcuts > Input Sources
Disable: Select the previous input source (^ space)
Updating VS Code dart and flutter extensions
Restarting the computer.
And voila! Ctrl + space now shows options in VS Code.

setting breakpoint angular cli .spec.ts code for debugging

I'm using angular2 cli and am following the test debugging instructions here official documentation. I'm able to search for the spec.ts source files which are in the app folder and set break points. However, I'm not able to do the same for the test files for components in other folder. The tests do run but I'm not able to find the source file in the chrome browser. Shall I edit some config file? I've tried to add the source files manually to the source in chrome but that doesn't help in setting the breakpoint. Any help is very much appreciated.
Do this and see what happens:
In a test that you cannot find, add a debugger; statement
Run ng test
When Karma is loaded in a new browser window, click the "Debug" button
Open the developer tools as soon as a new tab is opened in Chrome (reload the tab if you do this late)
See the "Source" devtools tab open to the file and break on the debugger statement. This should be the answer to your question.