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.44k stars 142 forks source link

Error: Method not found: '$checkedCreate' #139

Closed vishalrao8 closed 2 years ago

vishalrao8 commented 2 years ago

On running the build runner command I am getting these errors.

Screenshot (138)

My dev dependencies are:

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner: ^2.1.4
  flutter_gen_runner: ^4.0.0
  lint: ^1.7.2
  import_sorter: ^4.6.0

Flutter doctor result:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.5.3, on Microsoft Windows [Version 10.0.19043.1288], locale en-IN)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Android Studio (version 2020.3)
[√] VS Code (version 1.61.1)

Commands tried:

flutter clean
flutter pub get
flutter pub global activate flutter_gen
flutter pub run build_runner build --delete-conflicting-outputs

flutter pub global activate flutter_gen

Package flutter_gen is currently active at version 4.0.0.
Resolving dependencies...
The package flutter_gen is already activated at newest available version.
To recompile executables, first run `global deactivate flutter_gen`.
Installed executable fluttergen.
Activated flutter_gen 4.0.0.
lcdsmao commented 2 years ago

Hi @vishalrao8 Can you show the version of json_annotation in your pubspec.lock file? The $checkedCreate was introduced by json_annotation (>= 4.1.0) and it should be brought as the transitive dependency by flutter_gen_runner.

https://github.com/FlutterGen/flutter_gen/blob/e8927c0fddbeeea6ec8095fa38d907d0d3cc67e7/example/pubspec.lock#L294-L300

vishalrao8 commented 2 years ago
  json_annotation:
    dependency: transitive
    description:
      name: json_annotation
      url: "https://pub.dartlang.org"
    source: hosted
    version: "4.0.1"
vishalrao8 commented 2 years ago

Overriding dependency with the latest version fixed the issue but why transitive dependency didn't have the latest version by default?

  json_annotation:
    dependency: "direct overridden"
    description:
      name: json_annotation
      url: "https://pub.dartlang.org"
    source: hosted
    version: "4.3.0"
lcdsmao commented 2 years ago

Oh, I see: https://github.com/FlutterGen/flutter_gen/blob/e8927c0fddbeeea6ec8095fa38d907d0d3cc67e7/packages/core/pubspec.yaml#L21 Our dependency specify is bad. We should fix that.

@vishalrao8 Thanks for your report!