I'm trying to print('hi') inside Visual Studio Code's Debug Console using Dart/Flutter.
Whenever I perform a restart, it works just fine. As you can see in the debug console it prints: I/flutter: hi
Performing a restart takes up to one minute of loading time. This isn't very ideal.
Ideally I would prefer that print() displays on the console whenever I perform a hot reload (as this only a takes a few seconds).
Any help would be greatly appreciated!
You are running a flutter app. That's quite expensive even if your "app" is only a print. Depending on your machine, reloading or even restarting can take a while.
EDIT since the whole debugging setup required for flutter apps is run too.
If you want to run dart code only, consider creating a dart project without flutter.
Related
Coming from Eclipse, I am very used to the option to terminate the possible old and running instance of the code I'm working on. With VS Code, I instead have to select the console, press Ctrl+C, wait for the process to end and only then can I launch a new instance via Ctrl+F5 (same for debug/regular F5).
I was surprised to find no such option in VS Code, am I missing something or is this feature simply not supported ? If this is possible to configure somehow, how would I go about it ? Multiple tags because I'm not sure which part of VS Code would be responsible here. I am specifically developing in Java, if that is relevant.
Hello guys i am new to programming and i just installed vs code, everything is working fine except when i run the code the console comes and goes without me even seeing the output.So how do i make it stay. or how do i run the output inside the vs code terminal and just eliminate that pop up console.
The thing is i need to take screenshots of the output for my lecturer to see for future projects. Attached is a screenshot.the console is only here because it needs inputhere after input it just disappears
Background:
When the project is already running (npm run start), and I make changes, and save. Then VS Code rebuilds and runs the project. Great!
But it is very frustrating when VS Code is running, and you look through the code (without changing or saving anything), then often VS Code rebuilds for no reason.
When this happens, one loses the DevTools browser inspector, and has to start all over again.
Questions:
So, is there a way to prevent VS Code from automatically rebuilding without having changed or saved anything?
And is it possible to keep the auto-rebuild-on-save functionality at the same time?
I've been learning Dart/Flutter on VS Code and the Hot Restart/Reload was always automatic (if I changed a color in the code, it automatically showed up on screen). I have to manually trigger the action now. I have no idea what changed.
I'm using VS Code and iOS emulator. I can't run SDK on Android Studio right because I'm on the new mac M1 processor.
Solutions I've tried:
Opened other Flutter projects and verified the hot restart isn’t
working on any of them (its not an import error like other posts have suggested)
I ensured that I can manually hot restart from VSCode and terminal to see changes
Flutter Doctor shows no errors
I ran Flutter Upgrade from the terminal anyway
I uninstalled and reinstalled Dart and Flutter from VS Code
I ensured VS Code’s autosave feature was on
I ensured VS Code’s “Dart: Flutter Hot Reload on Save” (and Restart) were both checked
I tried running with and without debugging
I restarted my computer and VS Code
Edit: I just installed Android Studio and cannot get an automatic hot reload here either. I connected it to iOS emulator, turned on automatic saving after 2 seconds of being idle, and still have to manually reload. Alternatively, I can go to the menu and click "Save All" and it will reload to update the UI (without me having to click a hot reload or restart icon). But, it's still manual.
Edit: 2/25/21: A "fix" has been introduced in the v3.20.0 beta.
https://dartcode.org/releases/v3-20/
Ok, I was finally pointed in the right direction for an answer.
Apparently, the automatic hot reload after an IDE autosave was a bug that some users found to be a useful feature. The intended functionality was to only trigger a hot reload on a manual activation. Thus, the bug (feature) was "fixed" taking this functionality away.
Feedback shown a light on the fact that some people found the bug useful and there is now an indication that this functionality will be returned in the future.
https://github.com/Dart-Code/Dart-Code/issues/3110
Edit: 2/25/21: A "fix" has been introduced in the v3.20.0 beta.
https://dartcode.org/releases/v3-20/
VSCode can be buggy sometimes and this problem is arguably the most annoying. I had this happen to me last week when I decided to use a barrel file with flutter web.
Meaning, I had a folder with all the components exported and then would import only that one file, like this
And then wherever I wanted all those files to be, I would add
import barrell.dart
Now this worked perfectly fine when I was working with flutter on mobile, and the second I went to flutter web my app would not hot reload.
I share this with you to say that I found out about this by a process of elimination. Took me a little bit, but I created a new project from the bottom up, added in each part one by one, and then I found that it was this barrell file that was messing the hot-reload up..
So my best advice is to do the same - start fresh with a new project, add back the pieces one-by-one and if you do find out what is causing the hang-up, I implore you to share it here:
https://github.com/flutter/flutter/issues
Every so often the fans on my MacBook Pro start revving up and certain things in VS Code stop working, such as indentation and autocomplete etc.
When this happens I use Alfred App to figure out which process is causing an issue and it's usually one or more of the Code Helper processes launched by VS Code. Sometimes they'll a couple of them using way over 100% of the CPU. I kill the processes and then VS Code prompts me that the extension host has quit and to restart it. Once I do that the extensions start working again as normal. And then the whole thing repeats, just not all the time. For instance I'm writing this message now and Code is fine and not doing anything.
I'm wondering how do I debug this and figure out whether it's Code itself or an Extension causing the issue? If so how do I find out which extension it is?
Process Explorer is builtin in vscode.
It can be opened using menu by going Help => Open Process Explorer