As mentioned by many above it is due to Pub cache directory and project directory not being on the same drive, which is a known issue
Apart from moving both directories to the same drive there is a simple workaround of creating a symbolic junction/link for your project directory
Assuming you have Pub cache in C drive and your project in D drive:
- Create a hard symbolic link in C drive to your app directory using windows command prompt:
mklink /J C:\Development\your\project\directory\link D:\your\project\directory\real\path
- Open the project in your IDEs from symbolic junction/link
C:\Development\your\project\directory\link instead of D:\your\project\directory\real\path
- With this everything should work as expected, however if you open terminal in IntelliJ it might give you the real path instead of symbolic link, hence after opening terminal do
cd C:\Development\your\project\directory\link
- If you are using any custom or forked local dependencies from a relative path not absolute path and these are also in D(or any other non Pub cache) drive then you will need to create symbolic links for these paths as well e.g.:
mklink /J C:\Development\Flutter\custom_dependencies D:\Development\Flutter\custom_dependencies
If you use PoweShell then you need to use New-Item to create symbolic directory junction:
New-Item -ItemType Junction -Path "Link" -Target "Target"