Dart Analyzer terminated on flutter clean or flutter run - flutter

Whenever I use the command flutter clean or flutter run, the window "The Dart Analyzer has terminated." pops up in VS Code.
For flutter run I can specify that the analyzer terminates when it says "Running Gradle task 'assembleDebug'" in the console.
Here is the log after running flutter clean: https://hastebin.com/osovilenaj.swift
Can someone tell me the reason for this behaviour? I can simply click on restart, but it is annoying during my workflow.

Try to update and restart both PC and VSCode, see if the problem persist.
It generally used to happen to me when either my CPU is doing too much work or the RAM is exhausted, see if you have same problem either with CPU or RAM use a real device to test with USB Debugging enabled instead of Emulator.
also this might also help VSCode dart analyzer stopped recognizing flutter/dart code

Since something (Dart?) has been updated the error does not occurre anymore.

Related

Flutter running with no response after first installation in Windows

I'm new in flutter and trying to learn about it for the first time.
I'm following the instruction of flutter documentation in here
When in step to the setting environment, I follow the instruction here.
After restarting the pc, the next step I must running the command flutter doctor in cmd.
In this step, I get stuck because in cmd, flutter doesn't response anything.
I try to execute flutter inside VSCode It still stuck with loading.
I also try to running with android studio, Still the same, I get stuck with loading
What should I do?
I missed the important thing.
Just don't put it in the privilege directory.

Pub failed to delete entry because it was in use by another process

I was trying to configure my Flutter project to work on the web. I switched to the master channel using flutter channel master after doing this I tried to run flutter upgrade. I am now getting an infinite loop saying:
Building flutter tool...
Running pub upgrade...
Pub failed to delete entry because it was in use by another process.
This may be caused by a virus scanner or having a file
in the directory open in another application.
Error (1): Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (9 tries left)
Waiting for 0 seconds, press CTRL+C to quit ...
Running pub upgrade...
Pub failed to delete entry because it was in use by another process.
This may be caused by a virus scanner or having a file
in the directory open in another application.
Error (1): Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (8 tries left)
Waiting for 2 seconds, press CTRL+C to quit ...
Terminate batch job (Y/N)? Y
I have tried multiple things such as running flutter clean, trying to change back to the stable channel, deleting the cache folder in the flutter/bin directory, turning off my windows defender, nothing seems to work. Now when I try to run flutter doctor, or any other flutter command, I get the same infinite loop with the same message. I have also tried manually downloading and replacing my flutter sdk installation with a new installation, this did not work either. Is my only option at this point to delete flutter completely and reinstall from scratch?
I would appreciate any suggestions on how to fix this.
I ran my compiler as an administrator, and it worked for me.
Open your Android Studio or Visual Studio as an admin.
I was running into this issue and discovered that the problem was a new dependency that I added. In my case it was assets_audio_player: ^3.0.3+1, but of course it could be any dependency. Deleting it immediately fixed my problem.
Faced this problem and had to run "start ms-settings:developers" at terminal. It solved the issue.
On windows: Run vscode, or the terminal you are using, as admin to resolve the problem.
For Linux: I think some kind of sudo approach could do the trick.
run
flutter upgrade
in an external admin cmd console
use powershell (admin) to fix this I got same problem and fix this using Windows PowerShell (Admin). Just type flutter
switch your channel to stable or master using command "flutter channel stable"
I have solved it. I recommend instead of C:/src/flutter, you put the flutter folder inside C:/ direct. Would be like this:
C:/flutter
If that doesn't solve it, try pausing your anti-virus just for us to test. It could be that it is blocking the permissions on local disk C folder. It's not very common, but it can happen sometimes.
Running VS Code or Android Studio as Administrator, will probably solve the problem.

flutter error Could not find an option named "platforms"

I'm new to learning flutter when I try to crate a new project on android studio gives me a arror message in the event section enter image description here
The MESSAGE: [Could not find an option named "platforms". Run 'flutter -h' (or 'flutter -h') for available flutter commands and options.]
And another problem is flutter doctor does not see the android studio enter image description here
1(By the way, I want to use this version of flutter, please do not give a suggestion like update.)
2(this problem did not exist before, it happened after turning my computer off and on)
And sorry for my english mistakes
Thank you.
flutter version flutter_windows_v1.12.13+hotfix.9-stable
andorid studio version: 4.1.3
Is this the answer to your question about andorid studio?
and you need to install JDK
You are using the wrong flutter SDK. Too low information in your question. Make sure that you have the right path to flutter SDK in your IDE. Check that the flutter SDK directory has the appropriate structure, all needed files and cetera. Channel and version of flutter also may have an influence on this problem.
Got this today out of nowhere. Things were going well, but suddenly when I tried to relaunch the app from fresh, for the error Could not find an option named "target"
UPDATE:
This appears to happen when I switch branches and merge while app is running/flutter is attached. If you're using VS Code,
open your launch.json
change something, I decided to change type: "dart" to type: "notdart"
save
try to debug which fails
then revert that change.
This should fix the issue.
Previous Answer/If you're not using VS Code
What worked for me was to
flutter clean
close the editor (VS Code for me)
close the emulator
give a minute for things to close down
open task manager and kill any left over processes of dart.exe flutter.exe and java.exe and adb.exe (was doing Android)
start VS Code/Android Studio and try to debug again. (when prompted I chose to cold boot the emulator as well)
This takes a while as the emulator has to cold boot and since flutter clean was run, the compilation hadto start from scratch as well.

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!