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

Unable to generate files using build_runner #1023

Closed
PrimaelQuemerais opened this issue Jan 23, 2025 · 4 comments · Fixed by #1024
Closed

Unable to generate files using build_runner #1023

PrimaelQuemerais opened this issue Jan 23, 2025 · 4 comments · Fixed by #1024

Comments

@PrimaelQuemerais
Copy link
Member

Description

When using a recent version of Flutter (Stable channel : 3.27.2, dart 3.6.1) we are unable to generate files using the command
dart run build_runner build

The command first outputs the following warning

The language version (2.17.0) of this package (openfoodfacts) does not match the required range `^3.0.0`.

Edit pubspec.yaml to include an SDK constraint of at least ^3.0.0.

environment:
  sdk: ^3.0.0

And then lists all the formatter exceptions.

Can we bump the minimum dart version of the packages?

Expected behavior

Generate files

Stacktraces

[SEVERE] json_serializable on lib/src/model/product.dart:
An error `FormatterException` occurred while formatting the generated source for
  `package:openfoodfacts/src/model/product.dart`
which was output to
  `lib/src/model/product.json_serializable.g.part`.
This may indicate an issue in the generator, the input source code, or in the
source formatter.
Could not format because the source could not be parsed:

line 108, column 56 of .: Expected to find ')'.
    ╷
108 │         if (_$ProductTypeEnumMap[instance.productType] case final value?) 'product_type': value,
    │                                                        ^^^^
    ╵
line 109, column 34 of .: Expected to find ')'.
    ╷
109 │         if (instance.productName case final value?) 'product_name': value,
    │                                  ^^^^
    ╵
line 110, column 77 of .: Expected to find ')'.
    ╷
110 │         if (LanguageHelper.toJsonStringMap(instance.productNameInLanguages) case final value?) 'product_name_in_languages': value,
    │                                                                             ^^^^
    ╵
line 111, column 34 of .: Expected to find ')'.
    ╷
111 │         if (instance.genericName case final value?) 'generic_name': value,
    │                                  ^^^^
    ╵
line 112, column 77 of .: Expected to find ')'.
    ╷
112 │         if (LanguageHelper.toJsonStringMap(instance.genericNameInLanguages) case final value?) 'generic_name_in_languages': value,
    │                                                                             ^^^^
    ╵
line 113, column 38 of .: Expected to find ')'.
    ╷
113 │         if (instance.abbreviatedName case final value?) 'abbreviated_product_name': value,
    │                                      ^^^^
    ╵
line 114, column 81 of .: Expected to find ')'.
    ╷
114 │         if (LanguageHelper.toJsonStringMap(instance.abbreviatedNameInLanguages) case final value?) 'abbreviated_product_name_in_languages': value,
    │                                                                                 ^^^^
    ╵
line 115, column 29 of .: Expected to find ')'.
    ╷
115 │         if (instance.brands case final value?) 'brands': value,
    │                             ^^^^
    ╵
line 116, column 33 of .: Expected to find ')'.
    ╷
116 │         if (instance.brandsTags case final value?) 'brands_tags': value,
    │                                 ^^^^
    ╵
line 117, column 81 of .: Expected to find ')'.
    ╷
117 │         if (LanguageHelper.toJsonStringsListMap(instance.brandsTagsInLanguages) case final value?) 'brands_tags_in_languages': value,
    │                                                                                 ^^^^
    ╵
(75 more errors...)
[SEVERE] json_serializable on lib/src/model/localized_tag.dart:
An error `FormatterException` occurred while formatting the generated source for
  `package:openfoodfacts/src/model/localized_tag.dart`
which was output to
  `lib/src/model/localized_tag.json_serializable.g.part`.
This may indicate an issue in the generator, the input source code, or in the
source formatter.
Could not format because the source could not be parsed:

line 13, column 25 of .: Expected to find ')'.
   ╷
13 │         if (instance.id case final value?) 'id': value,
   │                         ^^^^
   ╵
line 14, column 27 of .: Expected to find ')'.
   ╷
14 │         if (instance.name case final value?) 'name': value,
   │                           ^^^^
   ╵
line 15, column 29 of .: Expected to find ')'.
   ╷
15 │         if (instance.lcName case final value?) 'lc_name': value,
   │                             ^^^^
   ╵
[SEVERE] json_serializable on lib/src/model/ordered_nutrient.dart:
An error `FormatterException` occurred while formatting the generated source for
  `package:openfoodfacts/src/model/ordered_nutrient.dart`
which was output to
  `lib/src/model/ordered_nutrient.json_serializable.g.part`.
This may indicate an issue in the generator, the input source code, or in the
source formatter.
Could not format because the source could not be parsed:

line 17, column 27 of .: Expected to find ')'.
   ╷
17 │         if (instance.name case final value?) 'name': value,
   │                           ^^^^
   ╵
line 20, column 35 of .: Expected to find ')'.
   ╷
20 │         if (instance.subNutrients case final value?) 'nutrients': value,
   │                                   ^^^^
   ╵
[SEVERE] json_serializable on lib/src/model/user.dart:
An error `FormatterException` occurred while formatting the generated source for
  `package:openfoodfacts/src/model/user.dart`
which was output to
  `lib/src/model/user.json_serializable.g.part`.
This may indicate an issue in the generator, the input source code, or in the
source formatter.
Could not format because the source could not be parsed:

line 15, column 30 of .: Expected to find ')'.
   ╷
15 │         if (instance.comment case final value?) 'comment': value,
   │                              ^^^^
   ╵
[SEVERE] json_serializable on lib/src/model/taxonomy_nova.dart:
An error `FormatterException` occurred while formatting the generated source for
  `package:openfoodfacts/src/model/taxonomy_nova.dart`
which was output to
  `lib/src/model/taxonomy_nova.json_serializable.g.part`.
This may indicate an issue in the generator, the input source code, or in the
source formatter.
Could not format because the source could not be parsed:

line 12, column 91 of .: Expected to find ')'.
   ╷
12 │         if (instance.name?.map((k, e) => MapEntry(_$OpenFoodFactsLanguageEnumMap[k]!, e)) case final value?) 'name': value,
   │                                                                                           ^^^^
   ╵
line 13, column 95 of .: Expected to find ')'.
   ╷
13 │         if (instance.synonyms?.map((k, e) => MapEntry(_$OpenFoodFactsLanguageEnumMap[k]!, e)) case final value?) 'synonyms': value,
   │ 

 ^^^^
...

Package information

version: 3.18.1

@monsieurtanuki
Copy link
Contributor

Hi @PrimaelQuemerais!
Probably fixed by #1021.

@monsieurtanuki
Copy link
Contributor

But with #1024 it would be even better ;)

@PrimaelQuemerais
Copy link
Member Author

Thanks @monsieurtanuki ! I'll try it soon

@PrimaelQuemerais
Copy link
Member Author

#1024 is indeed necessary

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

Successfully merging a pull request may close this issue.

2 participants