flutter_gen icon indicating copy to clipboard operation
flutter_gen copied to clipboard

[BUG]: Unable to build project when sub-package is used

Open dhirajhimani opened this issue 2 years ago • 10 comments

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

dhirajhimani avatar Mar 29 '23 14:03 dhirajhimani

Any update on this issue?

Raviteja11122 avatar Mar 31 '23 09:03 Raviteja11122

me too facing this issue on futter 3.7.10

egyleader avatar Apr 06 '23 13:04 egyleader

Pleases flutter_gen: ^5.2.0 remove it!

wasabeef avatar Apr 18 '23 06:04 wasabeef

But it gives following error

Bad state: Unable to generate package graph, no 'dart_tool/flutter_gen/pubspec.yaml' found.

dhirajhimani avatar Apr 18 '23 07:04 dhirajhimani

Temp workaround

this is a temp workaround to continue development with this package until this issue is fixed :

  1. comment all the sub-packages in pubspec.yaml
  2. 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
  1. run the build command flutter pub run build_runner build --delete-conflicting-outputs this will generate all the assets code .

  2. comment the fluttergen packages & configuration and uncomment the subpackages this is to avoid build conflicts with other code generation & use sub packages.

egyleader avatar Apr 20 '23 16:04 egyleader

thanks, luckily, i needed a small sub module, so i handled it.

dhirajhimani avatar May 04 '23 18:05 dhirajhimani

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

EArminjon avatar Sep 14 '23 09:09 EArminjon

Still having the problem on latest flutter. Any news?

JSBmanD avatar Feb 13 '24 22:02 JSBmanD

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

EArminjon avatar Feb 13 '24 23:02 EArminjon

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

JSBmanD avatar Feb 14 '24 03:02 JSBmanD

I cannot reproduce this with the example of the library using Flutter 3.16.

image

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.

AlexV525 avatar Mar 06 '24 21:03 AlexV525