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!
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.
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.
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.
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/
Solution (For VSCode):
flutter packages get
in pubspec.ymlIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With