Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
GabrielCR99 opened this issue Jun 24, 2022 · 10 comments
Closed
Labels
problem An unconfirmed bug.

Comments

@GabrielCR99
Copy link

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 GabrielCR99 added the problem An unconfirmed bug. label Jun 24, 2022
@silverhairs
Copy link

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'

@GabrielCR99
Copy link
Author

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

@silverhairs
Copy link

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

@GabrielCR99
Copy link
Author

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

@StanislawNagorski
Copy link

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'

@GabrielCR99
Copy link
Author

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

@DanielRomanMartinez
Copy link

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

@iliyami
Copy link

iliyami commented Aug 2, 2022

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!

@GabrielCR99
Copy link
Author

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!

@TUTI254
Copy link

TUTI254 commented Mar 25, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem An unconfirmed bug.
Projects
None yet
Development

No branches or pull requests

6 participants