If you encounter this error in Android Studio, and you have your source files in a different folder than the Flutter installation, you’ll have to move that Pub Cache folder to the same drive.
Move the folder located in C:\Users\<YOURNAME>\AppData\Local\Pub\Cache to the other drive. E.g. E:\src\Pub\Cache (or where ever you prefer)
Then set an Environment variable called PUB_CACHE to point to that new folder.
You might have to do a cache repair using:
flutter pub cache repair