0
votes

I recently started learning flutter/dart and I have a Problem that i couldn't solve. I've read in the official flutter documentation that you have to follow these three steps to install a package in flutter:

  1. Add the package (in my case: 'english_words: ^3.1.5') to the dependencies in the pubspec.yaml file.
  2. Run the 'flutter pub get' command to include the package to the '.packages' file.
  3. Add import 'yourpackagename' (in my case: 'package:english_words/english_words.dart') to the main.dart file.

My problem is though that VS marks it as an error if I try to do step 3: Target of the URI doesn't exist

Any ideas what I could do? I've installed the flutter and dart extensions for VS Code and also tried to restart the program but nothing worked.

2
Sometimes I run flutter clean and flutter pub get then I have to restart ide in order to import packageGabe
Sometimes depending on the speed of your computer, it can take the vscode flutter extension a while before it recognizes that you've installed a packageByteMe

2 Answers

1
votes

try running

flutter clean

if it is still not working, run:

flutter clean pub cache
0
votes

I had the same issue while doing the Google codelab, the solution for me was to open a terminal in VS Code and run the command flutter pub get and then try importing the pack again.