I have not used VSC for some days and when I started it today I got this error "The Flutter Daemon failed to start" and the problem that I see in the log is
[10:50:06 PM] [FlutterDaemon] [Error] Unhandled exception:
FileSystemException: Cannot open file, path = 'C:UsersgustaAppDataRoaming.flutter_tool_state' (OS Error: The process cannot access the file because it is being used by another process.
, errno = 32)
#0 _File.throwIfError (dart:io/file_impl.dart:629:7)
#1 _File.openSync (dart:io/file_impl.dart:473:5)
#2 _File.writeAsBytesSync (dart:io/file_impl.dart:598:31)
#3 _File.writeAsStringSync (dart:io/file_impl.dart:622:5)
#4 ForwardingFile.writeA…
I can flutter run
my application successfully.
Does anyone have an idea how to solve this?
I’ve tried uninstalling several (but not all) components and reinstalling, rebooting, updating Flutter, etc. The error remains unchanged.
2
Answers
try run this code in terminal
This error occurs when the
.flutter_tool_state
file is locked by another process. This file is used by Flutter to store information about the Flutter SDK location, version, and other settings.To fix this error, you can try the following steps:
Close all instances of Visual Studio Code and make sure no other process is using the
.flutter_tool_state
file.Navigate to the directory where the
.flutter_tool_state
file is located. This file is usually located in the root directory of your project.Delete the
.flutter_tool_state
file.Restart Visual Studio Code and open your Flutter project again.
If the error persists, you can try running the following command in the terminal to clear the Flutter tool state:
This command will delete all temporary files generated by Flutter, including the
.flutter_tool_state
file.If none of the above steps work, you can try reinstalling Flutter and Visual Studio Code.
Most of the time its the VS Code instance issue. I have also faced this on windows 10 many times. What worked for me was closing the VS Code and restarting it after 10 secs or so.