Flutter, DevDrive and Windows Defender
Like many SDKs, Dart/Flutter consist of hundreds of thousands of files. This easily becomes a performance problem on Windows, especially with AV solutions like Windows Defender, and results on slow code completion, analysis and generally sluggish performance of tools, e.g. in Visual Studio Code.
One solution to this problem is to disable the AV solution or just exclude the directories containing the SDKs. We will skip the explanation why this is generally a bad idea, but there is an alternative solution, namely Windows 11’s new Dev Drives, basically a VHDX using ReFs. Windows Defender does use a different mode of scanning files for all DevDrives, so this is a neat solution.
We just need to move all the Flutter/Dart SDK files to the newly created DevDrive (e.g. D:\Flutter), but that still does not yield the expected results. This is because the analyzer and public cache are still by default stored in the user’s home directories.
Moving these to the DevDrive significantly speeds up the analyzer, compilation, and all other tasks. These Environment Variables can be used to specify the new location of the folders:
ANALYZER_STATE_LOCATION_OVERRIDE | D:\.dart-Server |
PUB_CACHE | D:\.pub-cache |
GRADLE_USER_HOME | D:\.gradle |
Flutter, DevDrive and Windows Defender Read More »