enter image description here
I wish to import the package: flutter_displaymode/flutter_displaymode.dart’
But the above error occurred when I ran the flutter instruction using cmd. The development environment is Android Studio
I tried to close Android Studio, and also tried to use the cd command to switch the path to the root directory of flutter, but it still reported an error
2
Answers
The way you are trying to implement the dependency is wrong. Remember that dependency packages go in the project directory.
The message
Expected to find project root in current working directory
is because the project directory is not found to add the package.What you should do is open the projector directory in terminal and run
flutter pub add flutter_displaymode
Here’s more information how to add more dependencies.
https://docs.flutter.dev/packages-and-plugins/using-packages#using-packages
make sure you’re in the directory of your flutter project folder that contains pubspec.yaml and then run flutter pub add <your_required_file>