FlutterGen / flutter_gen

The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs.
https://pub.dev/packages/flutter_gen
MIT License
1.46k stars 146 forks source link

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

Closed dhirajhimani closed 7 months ago

dhirajhimani commented 1 year ago

Is there an existing issue for this?

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

Raviteja11122 commented 1 year ago

Any update on this issue?

egyleader commented 1 year ago

me too facing this issue on futter 3.7.10

wasabeef commented 1 year ago

Pleases flutter_gen: ^5.2.0 remove it!

dhirajhimani commented 1 year ago

But it gives following error

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

egyleader commented 1 year ago

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


3. run the build command `flutter pub run build_runner build --delete-conflicting-outputs`
this will generate all the assets code .

4.  comment the fluttergen packages & configuration  and uncomment the subpackages 
this is to avoid build conflicts with other code generation & use sub packages.
dhirajhimani commented 1 year ago

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

EArminjon commented 1 year ago

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
JSBmanD commented 7 months ago

Still having the problem on latest flutter. Any news?

EArminjon commented 7 months ago

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

JSBmanD commented 7 months ago

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

AlexV525 commented 7 months ago

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.