[BUG]: Unable to build project when sub-package is used
Is there an existing issue for this?
- [X] I have searched the existing issues
Version
5.2.0
Command type
build_runner (Default)
What happened?
Create a sub-package in the main project:- flutter create --template=package demo
After adding the entry in the pubspec.yaml, for the local package, the build_runner doesn't work, but if the flutter_gen is removed, it works.
Relevant a pubspec.yaml.
name: app
dependencies:
demo:
path: demo/
flutter:
sdk: flutter
dev_dependencies:
build_runner: ^2.3.3
flutter_gen: ^5.2.0
flutter_gen_runner: ^5.2.0
flutter_gen:
output: lib/app/generated/
integration:
flutter_svg: true
import_sorter:
ignored_files:
- \/lib\/*.g.dart
- \/lib\/*.freezed.dart
- \/lib\/*.config.dart
- \/lib\/*.chopper.dart
- \/lib\/*.mocks.dart
flutter:
generate: true
uses-material-design: true
assets:
- assets/images/
- assets/icons/
- assets/fonts/
- assets/env/
Relevant log output
The pubspec.lock file has changed since the .dart_tool/package_config.json file was generated, please run "flutter pub get" again.
pub finished with exit code 65
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Any update on this issue?
me too facing this issue on futter 3.7.10
Pleases flutter_gen: ^5.2.0 remove it!
But it gives following error
Bad state: Unable to generate package graph, no 'dart_tool/flutter_gen/pubspec.yaml' found.
Temp workaround
this is a temp workaround to continue development with this package until this issue is fixed :
- comment all the sub-packages in pubspec.yaml
- add the required packages & configuration for fluttergen
dev_dependencies:
flutter_gen: ^5.3.0
flutter_gen_runner: ^5.3.0
build_runner: ^2.2.0
flutter_gen:
output: lib/generated/assets
integrations:
flutter_svg: true
-
run the build command
flutter pub run build_runner build --delete-conflicting-outputsthis will generate all the assets code . -
comment the fluttergen packages & configuration and uncomment the subpackages this is to avoid build conflicts with other code generation & use sub packages.
thanks, luckily, i needed a small sub module, so i handled it.
I create a reproductible project: https://github.com/EArminjon/flutter-issue
flutter pub get && flutter pub run build_runner build --delete-conflicting-outputs
The pubspec.lock file has changed since the .dart_tool/package_config.json file was generated, please run "flutter pub get" again.
pub finished with exit code 65
Still having the problem on latest flutter. Any news?
Still having the problem on latest flutter. Any news?
Upgrade flutter to the latest release. I got this issue With 3.7 and no longer with 3.16
Still having the problem on latest flutter. Any news?
Upgrade flutter to the latest release. I got this issue With 3.7 and no longer with 3.16
I'm on 3.16.5, still have this issue, need to delete lock file every time issue appears
I cannot reproduce this with the example of the library using Flutter 3.16.
As @wasabeef suggested above, removing flutter_gen as a dependency might help to solve this.
Closing this as cannot reproduce, and please submit a minimal reproducible example (project with sub-package) with a new issue.