error: Target of URI doesn’t exist - All possible solutions

Mahi!
feedflood
Published in
2 min readAug 18, 2019

This is a very common error while developing apps with flutter.

I have found 2 causes and a remedy for each of the error and they can solve them almost all the times.

Case 1: forgot to include the package in pubspec.yaml

This will be the first case always. If you’ve used a package in your app somewhere and imported it on the top, without adding it to the app’s pubspec.yaml file found in the root directory of your app.

Make sure you have added the dependency of the package along with a proper version number and after saving the flutter pub get command worked fine with the exit code 0 (It should run automatically when you save). Also, make sure you add a version number and not ANY so that your app doesn’t break with some future version of the package update.

Case2: For no obvious reasons

If you see that you’ve clearly followed everything said in Case1 but still the error persists then it may be because dart analyzer is not able to track the change. In that case, you just close and restart the project and it should recognize the imported package.

These are the two ways that have worked for me. There are also some solutions in the comments which may help. Please check them out as well.

If you like my work please consider supporting me

Thanks:)

--

--