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_OVERRIDED:\.dart-Server
PUB_CACHED:\.pub-cache
GRADLE_USER_HOMED:\.gradle

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top