hive icon indicating copy to clipboard operation
hive copied to clipboard

hive_generator doesn't generate *.g.dart files using super-parameters feature

Open GabrielCR99 opened this issue 4 years ago • 10 comments

Steps to Reproduce

  1. Use the latest Dart stable version on project sdk (in my case, 2.17.5)
  2. Run flutter pub run build_runner build or flutter_pub_run build_runner watch
  3. Wait
Running `flutter.bat pub run build_runner build --delete-conflicting-outputs`
Current working folder: `e:\FlutterProjects\Inventario\Inventario.Mobile`

[INFO] Generating build script...
[INFO] Generating build script completed, took 318ms

[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 62ms

[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 316ms

[INFO] Running build...
[INFO] Running build completed, took 17ms

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 36ms

[SEVERE] hive_generator:hive_generator on lib/app/app_widget.dart (cached):

This builder requires Dart inputs without syntax errors.
However, package:inventario_mobile/app/app_widget.dart (or an existing part) contains the following errors.
app_widget.dart:10:20: This requires the 'super-parameters' language feature to be enabled.

Try fixing the errors and re-running the build.

[SEVERE] Failed after 63ms
pub finished with exit code 1

Code sample

flutter pub run build_runner build

Version

  • Platform: Android (12), Windows 10
  • Flutter version: 3.0.3
  • Hive version: 2.2.2

GabrielCR99 avatar Jun 24 '22 17:06 GabrielCR99

I think this is because you used a feature from Dart 2.17 while your environment’s min version is lower than 2.17.

In your pubspec.yaml On the environment change the min SDK version to 2.17 or 2.17.1

environment:
  sdk: '>=2.17.1 <3.0.0'

silverhairs avatar Jun 24 '22 17:06 silverhairs

I think this is because you used a feature from Dart 2.17 while your environment’s min version is lower than 2.17.

In your pubspec.yaml On the environment change the min SDK version to 2.17 or 2.17.1

environment:
  sdk: '>=2.17.1 <3.0.0'

I've actually changed my environment's min version to 2.17.5. Just forgot to add the print to the issue, sorry. But anyway, here's the print to prove it

image

GabrielCR99 avatar Jun 24 '22 17:06 GabrielCR99

I think this is because you used a feature from Dart 2.17 while your environment’s min version is lower than 2.17. In your pubspec.yaml On the environment change the min SDK version to 2.17 or 2.17.1

environment:
  sdk: '>=2.17.1 <3.0.0'

I've actually changed my environment's min version to 2.17.5. Just forgot to add the print to the issue, sorry. But anyway, here's the print to prove it

image

Maybe try flutter clean then flutter pub get and generate the files again

silverhairs avatar Jun 24 '22 18:06 silverhairs

I think this is because you used a feature from Dart 2.17 while your environment’s min version is lower than 2.17. In your pubspec.yaml On the environment change the min SDK version to 2.17 or 2.17.1

environment:
  sdk: '>=2.17.1 <3.0.0'

I've actually changed my environment's min version to 2.17.5. Just forgot to add the print to the issue, sorry. But anyway, here's the print to prove it image

Maybe try flutter clean then flutter pub get and generate the files again

Tried it. I tried flutter clean, flutter pub get, flutter pub cache repair, everything related from flutter pub command. No success. My guess is that this error is because of hive_generator using an old version of Dart's sdk, as seen in this print image

GabrielCR99 avatar Jun 24 '22 18:06 GabrielCR99

Hi all, We have the same problem as @GabrielCR99. None of the cleaning and rebuilding helps, and of course we are at sdk: '>=2.17.1 <3.0.0'

StanislawNagorski avatar Jul 11 '22 07:07 StanislawNagorski

Unfortunately, untill any collaborator see this issue or knows any way to solve it, the way is to not use super-parameters feature, which is kinda sad because this is such an interesting feature and helps to reduce code

GabrielCR99 avatar Jul 11 '22 14:07 GabrielCR99

I had the same problem and removing the pubspeck.lock and launching again the command pub spec get to regenerate the file. Solved it

DanielRomanMartinez avatar Jul 14 '22 10:07 DanielRomanMartinez

I had the same problem, I upgraded my hive and hive_flutter package to the latest version and remove the pubspec.lock file, and then run a flutter pub get. After that, I just run flutter packages pub run build_runner build, and allright!

iliyami avatar Aug 02 '22 20:08 iliyami

It seems like deleting pubspeck.lock or even upgrading build_runner on the project's pubspec.yaml solve this issue. I'll close it since I also solved the problem!

GabrielCR99 avatar Aug 02 '22 20:08 GabrielCR99

It seems like deleting pubspeck.lock or even upgrading build_runner on the project's pubspec.yaml solve this issue. I'll close it since I also solved the problem!

its wierd but atleast it works!

TUTI254 avatar Mar 25 '23 16:03 TUTI254