flutter not showing devices in VS code and flutter commands also not working - flutter

I face this problem after every 2,3 days that VS code doesn't show devices even they don't show chrome or edge. Then I run flutter commands but flutter commands are also not working. no error, no output in CMD. Please tell me how to solve this problem.

This issue is caused by an extension.
This was how I solved my mine
just search for the extension uninstall or disable it.
Restart your vscode again.
Happy coding

Related

VScode Dart/Flutter not working out side of terminal?

All I wanted was to make a simple flutter/dart calculator in VS code... but I've been suffering tech issues for the last 2 days trying to get it working.
Right now my problem is basically VS code is unresponsive outside of the terminal I think.
Example: in terminal when I run 'flutter doctor -v' I get
running flutter doctor in terminal
As you can see everything works fine, but when I do ctrl+shift+p and run flutter doctor it never finishes loading in the bottom right, just stating 'flutter doctor -v: running...' same with when I run Flutter: New Project.
Also when I select the No Device in the bottom right of the VS code screen to choose an emulator to run it does the same thing, just loading for ever... I have no clue why. I followed about 10 youtube tutorials on how to set up VS code for flutter, after non of them worked I uninstalled and reinstalled VS code, Android Simulator, flutter, cleared settings and fresh installing each and this problem persists.
Please check you are on the latest version of VS Code and the Dart extension. This issue should've been resolved in the Dart extension version v3.38.0.
https://github.com/Dart-Code/Dart-Code/issues/3877
If you still see this in the latest version, please file an issue on GitHub for me to take a look.

Weird behavior of flutter and dart commands in PowerShell and CMD

I'm relatively new to Flutter but I already have developed and finished some Apps in Flutter.
Recently I noticed a weird behavior of commands with the keywords "dart" or "flutter" in it.
Here is an example:
I was trying to migrate an existing project to the new dart null-safety and typed the command dart migrate into my Visual-Studio-Code Terminal.
I was expecting an output like Migrating C:\.... as a response but instead got these three lines:
The command "git" is either misspelled or could not be found.
Building flutter tool...
Running pub upgrade...
and then the expected output:
Migrating C:\<project path>...
and so on.
So basically the commands work as they would normally do but I get these three lines before the output everytime. And it's not only with this command. Also basic commands like dart help or flutter doctor will get these three lines.
I don't know what I am doing wrong. I uninstalled Flutter and also removed it from the PATH and then reinstalled it freshly but it's still the same. I also searched the web but didn't found anyone who has the same problem.
Any help and explanation would be great. Thank you for your time :)
I think I know where the problem is. I ran the commands directly when I opened PowerShell. But the directory was something like C:\Windows\ and then it won't work.
After I did cd C:\Users\User all commands will work as expected.
I was just thinking that it doesn't matter from where I run dartand fluttercommands obviously you have to be in your user directory that they will work properly.

Could not find an option named "web-server-debug-protocol" when running a Flutter project through VSCode

I am using VSCode ad my Flutter development IDE. It worked well until this afternoon. When I ran the project, Could not find an option named "web-server-debug-protocol"showed up. I have no idea what goes wrong.
I googled "web-server-debug-protocol" and only found two links showed that it exists in the flutter_command.dart.
Did anyone meet the similar problem? Any suggestions about that?
Thanks!
UPDATE
I solved this issue by upgrading my Flutter.
echo.
I reinstalled Flutter extension in VS Code and it worked properly.
good flutter life!
For me restarting the VS Code did the Job.
Just restart VS code. It often happens when you switch between Flutter channels, but restart should fix it...
I had the same problem, I just upgraded Flutter and it works.

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.

vscode fails to HotReload on latest Flutter version

After latest Flutter 1.0 stable and Dart update to vscode, I,m unable to use hotreload from vscode. If I run it from a terminal everytnhing works fine. Flutter doctor has no complains and I'm not sure how to fix it. I tried to uninstall flutter and dart from vscode but no luck so far. The error I get is
../../third_party/dart/runtime/vm/object.h: 8954: error: Handle check
failed: saw Instance of 'HomePage' expected Closure
I searched to find a solution but so far no luck.
This appears to be a bug in Dart or Flutter. It's possible it's the same as this one:
https://github.com/flutter/flutter/issues/24710
Can you reproduce in a small sample that you could easily attach to that issue and add some notes on your environment (what platform, what device, etc.) and if you get a full stack trace dumped when this happens, include that too.
Thanks!