Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Target of URI doesn't exist 'package:english_words/english_words.dart'

Tags:

flutter

dart

I'm learning to use Flutter using Android Studio. I'm going through step by step doc provided by Flutter. At Step:2 Use an external package I'm getting issue importing the english_words package. I have properly added the package in pubspec.yaml and clicked Packages Get which added the dependency but at the time of importing the package in lib/main.dart it is saying

Target of URI doesn't exist 'package:english_words/english_words.dart'.

I have seen many questions on StackOverflow but none of them helped me. Please help!

like image 671
Vaibhav Dhunde Avatar asked Aug 12 '18 14:08

Vaibhav Dhunde


People also ask

How do I add English words to flutter?

Firstly, we should add the dependency of two packages to our pubspec. yaml. Next, right away we can start using the English words package inside any widget, just like the following. final wordPair = WordPair.

Where is Pubspec Yaml?

yaml file, often referred to as the pubspec. A basic pubspec is generated when you create a new Flutter project. It's located at the top of the project tree and contains metadata about the project that the Dart and Flutter tooling needs to know.


3 Answers

For some packages, once you do all the process described by the other answers to this question, you have to close the Android project and open it again. As well as the emulator.

Some packages need the restart, others do not need it.

like image 79
Isaac Benitez Avatar answered Oct 27 '22 02:10

Isaac Benitez


After adding the package in the pubspec.yaml file, you need to execute the command flutter packages get or click on "Packages Get" in the action ribbon at the top of pubspec.yaml file.

Then the dependency and any transitive dependency will be added to the .packages file.

Check this:

https://flutter.io/using-packages/

like image 10
Peter Haddad Avatar answered Oct 27 '22 01:10

Peter Haddad


Solution (For VSCode):

  1. Run flutter packages get in pubspec.yml
  2. Restart VSCode
like image 5
iMujtaba8488 Avatar answered Oct 27 '22 01:10

iMujtaba8488