After I have updated Flutter to v1.22 using code generation with build_runner
was not working. I was told that the proper command to use in this version was:
dart pub run build_runner watch --delete-conflicting outputs
However, I receive the following error:
Could not find a file named "pubspec.yaml" in "C:\Users\jpiab\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\_fe_analyzer_shared-2.2.0".
I have no idea why it is looking for pubspec.yaml
in that folder, since that folder is not the current working directory.
--- EDIT ---
The file exists in path:
C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-2.2.0
dart is just looking for it in the wrong place. Any ideas on how to fix it?
Every Flutter project includes a pubspec. 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.
The pubspec. yaml file is transversal to all apps and packages - it is where we add metadata to our project, stipulate the Dart and Flutter SDK constraints, manage the dependencies and also set Flutter-specific configurations.
You can go to the pubspec. yaml file and add dependencies ,under dependencies and then packages get will do the work. or you can run flutter pub get in the terminal.
I solved for me. I use Android Studio in Ubuntu 20.04.01 LTS.
Firstly run this command:
flutter pub get
After run this command:
flutter packages pub run build_runner build
Or:
flutter packages pub run build_runner watch
Source: https://github.com/flutter/flutter/issues/50092
That same error I had and I resolved it by aligning my dependencies. Check if your build_runner is in the same line as flutter_test if you added it to dev_dependencies.
Error Corrected
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: [latest]
My Error
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: [latest]
If 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