Autocomplete/Intellisense not working for dart/flutter in VSCode - flutter

Even with the CTRL+SPACE shortcut, the options I get are nowhere near relevant to the code.
I created a new file named questions.dart in the lib folder along with main.dart. In main.dart the code autocomplete works fine but in question.dart, it doesn't. Also, the syntax is not getting highlighted as well in the new file.
For questions.dart
For main.dart

Restart the Dart Analysis Server. If that doesn't work, restart your IDE.
This happens to me occasionally. I believe it's an issue with the Dart Analysis Server. Usually, restarting the Dart Analysis Server fixes it.
To restart the Dart Analysis Server. Press ctrl + shift + p. Then search look for a command called Dart: Restart Analysis Server. If it doesn't work restart your IDE.

I'm facing the same issue here. I managed to solve it by switching flutter channel from master to beta. Now autocomplete works, but sometimes things still get crazy.

Related

VS Code Terminal command extra first letter

In vs code terminal I'm getting first letter of command twice. it's not causing any problem but it's kind of annoys me to watch the wrong command. I'm not writing any letter twice, the first letter of all commands gets repeated automatically.
as you can see there are 2 commands first one ppython first p automatically got repeated even though i wrote python it makes it ppython. and the first p that got repeated won't delete from there even if i spam backspace so many time . the I tried to clear the command till first p and as I'm not able to remove first p from terminal I just wrote ython in front of it. it looks proper now python. but I got a error response as ython is not recognized command. this same happens with other commands too like cd converts to ccd.
Edit : I Re-installed vs code then but that didn't resolved my problem, when I installed it again all my extensions were there already installed then I deleted vs code again then went to the vs code's location there was a folder name .vscode I deleted that then installed vs code again now all the extensions were deleted from vs code but I'm still having the main problem . that doesn't resolved it. and I'm not getting that error while using other terminals like git bash and I'm getting this error only when I open python file's folder not when I open a react app folder or normal js or other language.
I also tried reseting the default setting from setting.json file as one of the answers suggested but that doesn't worked.
It's hard to answer this without knowing your configuration. What plugins have you installed? Try disabling those related to the terminal emulator one by one to see if they're causing any issues.
In doing this, you would naturally restart the terminal emulator as well. If the problem persists, check if you get this erroneous doubling on a terminal emulator outside of VS Code (Terminal or PowerShell).
If nothing works, try reinstalling the interpreter and also VS Code. Especially the latter, if this seems to affect only the terminal emulator within VS Code.
It's really hard to answer your question without knowing your vs code configuration setting.
The easiest way is you can reset your vs code to default
The Steps
Go to View > Command Palette or press Cmd + Shift + P (macOS) or Ctrl + Shift + P (Windows).
Search for open settings json and select Preferences: Open Settings (JSON) which show ups from the result list.
If you’ve been working with VS Code for a while and installed a lot of things and made a lot of changes, you’ll find there’s a lot of stuff in this file:
Delete everything inside the root braces and save the file
Relaunch your VS Code.
(This step is optional) In case you want to not only reset VS Code but also remove all installed extensions:
Delete the ~/.vscode/extensions folder if you’re on a Mac.
Delete the %USERPROFILE%.vscode\extensions folder if you’re using Windows.

Dart syntax highlighting is not working in vs code

i have been using vs code for flutter for 3 months and now i got into this issue
syntax prediction works and flutter run is also working but syntax color is gone
Also i have uninstalled every extensions and reinstalled vs code
here is the console screenshot
It appears that one of the files in the Dart extension may be corrupt on your disk (syntaxs/dart.json). I would try to uninstall the extension and re-install it.
If that does not help, please check the contents of the .vscode-extensions folder in your home directory in the Dart-Code folder syntaxes/dart.json and see why it is not valid json.
I've seen this once before (https://github.com/microsoft/vscode/issues/73134) though it's not clear why it happened.

Can not change or remove logs from project

I'm facing a weird issue. I inserted some logs just like below:
log('whatever messager you want');
Now, no matter if I comment them or change the message inside them, nothing changes. Thay remain there the way I set it the first time. It happens in both VSCode and Android Studio.
I already tried:
deleting and installing the app again.
reload vscode window
close and reopen vscode
restart windows
Nothing worked for me.
Have you tried to run
flutter clean
in your project directory?
In my case, Ctrl + Shift + B was displaying No build task to run found and ctrl + F5 wasn't updating my code changes when using VSCode.
The solution I found was to migrate to Android Studio. I relaunched the emulator from Android Studio and the Run button updates the app correctly.

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.

Visual Studio Code extension host timeout during debugging

What I'm doing
I am using the instructions on this page to generate a Hello World extension for Visual Studio Code. I've generated the extension using Yeoman and am now simply trying to launch the hello world extension in an Extension Host instance of VSCode using the debugger by hitting F5.
The problem
I am receiving a notification at the top of the original VSCode window that reads, "Error cannot connect to runtime process (timeout after 3000ms) launch.json | Close".
This error appears slightly before the Extension Host window opens.
Once the extension host window opens, it spins a bit and then shows this warning at the top of its window:
The warning reads, "warn plugin host did not start in 10 seconds, it might be stopped on the first line and needs a debugger to continue | Close".
Seems like I just need some way of making the runtime timeout longer but I haven't found out how to do this.
My environment:
OSX 10.10.5 Yosemite
Node 0.12.7 or 4.2.1 (I've tried both)
Visual Studio Code 0.10.1
EDIT: This only happens when using Typescript in the Yeoman generator. I tried the Javascript version and it works fine.
Given that this seems to be a bug, I've opened this Github issue with the code yeoman generator.
It's simple but I spent 1 hour to find the issue.
I think mistake I did is first I created launch json and installed chrome debugger and then I modified launch.json for chrome launch so did not work.
So I tried below and it worked.
Deleted launch.json and reinstalled chrome debugger extension and
restart visual studio code and create lanch.json after these steps it worked :)
Try it may work.
This happens to me as well. I simply reload the extension by pressing F5 again and it usually works. Rarely it will fail twice in a row and then will work on the third time.
Not really a "solution" to the problem, but it's worked so far.
Find %VSCodeHome%\resources\app\extensions\node-debug\out\node\nodeDebug.js and change wait time in line 203.
// try to attach
setTimeout(function () {
_this._attach(response, port, 3000);
}, 2000);
into time working for you, like:
// try to attach
setTimeout(function () {
_this._attach(response, port, 10000);
}, 2000);
Worked for me.
Accessing the Internet through a proxy may also cause this. It's due to the source map downloader doesn't use your proxy, so the download always times out after attempting to connect for a long time.
For those who encounter this, try the workaround here.
I am also running into this same error, but I'm seeing this with the example language server example repo that's in the documentation: https://github.com/Microsoft/vscode-languageserver-node-example