Error while running built value generator

2.1k Views Asked by At

I got an error while trying to use built value generator

This was the error that i got.

[INFO] Running build...
[INFO] Generating SDK summary.
[SEVERE] built value generator:built value on lib/json_parsing.dart:
Bad state: Unexpected diagnostics:
C:\src\flutter\bin\cacheldart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] built_value_generator:built_value on lib/json_parsing.dart:

Bad state: Unexpected diagnostics:
C:\src\Flutter\bin\cache\dart-sdk\lib\core uri.dart:3259:39 - Expected an identifier.

[SEVERE] built_value_generator:built_value on lib/json_parsing.dart:

Bad state: Unexpected diagnostics:
C:\src\flutter\bin\cache\dart-sdk\lib\coreluri.dart:3259:39 - Expected an identifier.

the class which i was using running the built value generator on

import 'package:built_value/built_value.dart';

part 'src/json_parsing.g.dart';

abstract class Article implements Built<Article, ArticleBuilder> {
  Article._();
  factory Article([void Function(ArticleBuilder) updates]) = _$Article;
}
2

There are 2 best solutions below

0
On

It looks like build_runner version 1.10.1 pinned the version of analyzer to 0.39.14.

Try to update build_runner: build_runner: ^1.10.1 without adding dependency_overrides: and see.

0
On

As mentioned by @Mohammad on the comments, and from this issue, just add this to pubspec.yaml:

dependency_overrides:
  analyzer: '0.39.14'

Note, this is a sibling of dependencies and dev_dependencies.