I\'ve just setup my Macbook for flutter development,
So I downloaded flutter sdk, and placed it in my Documents. After, I setup my path variable to
Open the command palette (ctrl+shift+p), type flutter: get packages (should autocomplete); after it resolves open the command palette again and type reload window and execute the command. This should resolve the issue as quickly as possible.
If you have used the flutter packages get
command and the error still persists, you can simply reload VS code the Developer: Reload Window
command. Simply type that in after pressing Ctrl+Shift+P
(Cmd+Shift+P
for Mac users). It will clear the error. It's like refreshing VS Code.
Warning! This package referenced a Flutter repository via the .packages file that is no longer available. The repository from which the 'flutter' tool is currently executing will be used instead.
running Flutter tool: /opt/flutter previous reference : /Users/Shared/Library/flutter This can happen if you deleted or moved your copy of the Flutter repository, or if it was on a volume that is no longer mounted or has been mounted at a different location. Please check your system path to verify that you are running the expected version (run 'flutter --version' to see which flutter is on your path).
Checking the output of the flutter packages get
reveals that the reason in my case was due to moving the flutter sdk.
I was trying use the audio players flutter package. Once I added it to pubspec.yaml and tried to import it to main.dart, I got the same error.
I tried to restart my IDE but that didn't help so i tried running
flutter packages pub cache repair
and it worked.
Basically
Start debugging your project
Most probably , your errors will be fixed by then
Hope it works for you
If you change the property name
in pubspect.yaml
all your package in lib folder turn to red with the error Target of URI doesn't exist...