3

I'm using the latest version of all these packages.

dependencies
  json_annotation: ^4.5.0

dev_dependencies:
  json_serializable: ^6.2.0
  build_runner: ^2.1.10

I also found that json_serializable: 6.1.5 added support for enhanced enums. But when I run flutter pub build_runner build on

@JsonEnum(fieldRename: FieldRename.snake)
enum Foo {
  helloWorld,
  bar;
}

I get this error:

This builder requires Dart inputs without syntax errors. However, package:example/main.dart (or an existing part) contains the > following errors. main.dart:15:8: This requires the 'enhanced-enums' language feature to be enabled.

I also noticed that all these packages's pubspec.yaml are still not using the Dart SDK 2.17.0. I manually changed them to 2.17.0.

iDecode
  • 22,623
  • 19
  • 99
  • 186

1 Answers1

2

The only way that i found to run build-runner without errors was adding --enable-experiment=enhanced-enums to the build_runner command so the complete command should be flutter pub run build_runner build --delete-conflicting-outputs --enable-experiment=enhanced-enums. This is only a temporal fix to be able to run the build_runner without errors