Scott Kilbourn
Scott Kilbourn

Reputation: 1586

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:

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.

Upvotes: 14

Views: 36957

Answers (10)

THANGSTAR
THANGSTAR

Reputation: 81

This fixed for me:

flutter upgrade --force

Upvotes: 0

toolnin
toolnin

Reputation: 144

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.

Upvotes: 0

Yasser159
Yasser159

Reputation: 1

Check to make sure Android Studio is not on low power mode

Menu>File>Low Power Save Mode

1

Upvotes: 0

Faheem Ahmad
Faheem Ahmad

Reputation: 173

just do flutter clean then flutter create. and then flutter pub upgrade, and also see if your flutter SDK is latest or not.

Upvotes: 0

Ehsan Akbari
Ehsan Akbari

Reputation: 21

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

Upvotes: 2

Shivam Modi
Shivam Modi

Reputation: 150

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.

Upvotes: 0

Shimron Alakkal
Shimron Alakkal

Reputation: 145

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.

Upvotes: 1

Deven Bhadane
Deven Bhadane

Reputation: 221

Go to pubspec.yaml and hit save or run get packages. It worked for me, hope it helps

Upvotes: 22

Sourav Ganguly
Sourav Ganguly

Reputation: 21

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.

Upvotes: 1

Danny Tuppeny
Danny Tuppeny

Reputation: 42453

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).

Upvotes: 10

Related Questions