I get this error when I try to run flutter pub run build_runner build
. The last thing that I remember was changing the @JsonKey(name: "key")
in one of my remote response class. This is my first time getting this error when running the build_runner.
What exactly happen in this error code? And how to fix it?
(edit)
I'm using Flutter version 3.19.2
Failed to build build_runner:build_runner:
../../../../.pub-cache/hosted/pub.dev/dart_style-2.3.6/lib/src/source_visitor.dart:1287:38: Error: Type 'ExtensionTypeDeclaration' not found.
void visitExtensionTypeDeclaration(ExtensionTypeDeclaration node) {
^^^^^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/dart_style-2.3.6/lib/src/source_visitor.dart:2629:43: Error: Type 'RepresentationConstructorName' not found.
void visitRepresentationConstructorName(RepresentationConstructorName node) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/dart_style-2.3.6/lib/src/source_visitor.dart:2635:39: Error: Type 'RepresentationDeclaration' not found.
void visitRepresentationDeclaration(RepresentationDeclaration node) {
^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/dart_style-2.3.6/lib/src/source_visitor.dart:1287:38: Error: 'ExtensionTypeDeclaration' isn't a type.
void visitExtensionTypeDeclaration(ExtensionTypeDeclaration node) {
^^^^^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/dart_style-2.3.6/lib/src/source_visitor.dart:2629:43: Error: 'RepresentationConstructorName' isn't a type.
void visitRepresentationConstructorName(RepresentationConstructorName node) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/dart_style-2.3.6/lib/src/source_visitor.dart:2635:39: Error: 'RepresentationDeclaration' isn't a type.
void visitRepresentationDeclaration(RepresentationDeclaration node) {
^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/dart_style-2.3.6/lib/src/front_end/ast_node_visitor.dart:623:39: Error: Type 'ExtensionTypeDeclaration' not found.
Piece visitExtensionTypeDeclaration(ExtensionTypeDeclaration node) {
^^^^^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/dart_style-2.3.6/lib/src/front_end/ast_node_visitor.dart:1543:44: Error: Type 'RepresentationConstructorName' not found.
Piece visitRepresentationConstructorName(RepresentationConstructorName node) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/dart_style-2.3.6/lib/src/front_end/ast_node_visitor.dart:1551:40: Error: Type 'RepresentationDeclaration' not found.
Piece visitRepresentationDeclaration(RepresentationDeclaration node) {
^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/dart_style-2.3.6/lib/src/front_end/ast_node_visitor.dart:623:39: Error: 'ExtensionTypeDeclaration' isn't a type.
Piece visitExtensionTypeDeclaration(ExtensionTypeDeclaration node) {
^^^^^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/dart_style-2.3.6/lib/src/front_end/ast_node_visitor.dart:629:49: Warning: The null-check pattern will have no effect because the matched type isn't nullable.
Try replacing the null-check pattern with its nested pattern.
if (node.constKeyword case var keyword?) keyword
^
../../../../.pub-cache/hosted/pub.dev/dart_style-2.3.6/lib/src/front_end/ast_node_visitor.dart:1543:44: Error: 'RepresentationConstructorName' isn't a type.
Piece visitRepresentationConstructorName(RepresentationConstructorName node) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/dart_style-2.3.6/lib/src/front_end/ast_node_visitor.dart:1551:40: Error: 'RepresentationDeclaration' isn't a type.
Piece visitRepresentationDeclaration(RepresentationDeclaration node) {
^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/dart_style-2.3.6/lib/src/front_end/piece_factory.dart:892:7: Error: Type 'RepresentationDeclaration' not found.
RepresentationDeclaration? representation,
^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/dart_style-2.3.6/lib/src/front_end/piece_factory.dart:386:46: Error: Non-nullable variable 'forPartsPiece' must be assigned before it can be used.
var forPiece = ForPiece(forKeywordPiece, forPartsPiece, bodyPiece,
^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/dart_style-2.3.6/lib/src/front_end/piece_factory.dart:892:7: Error: 'RepresentationDeclaration' isn't a type.
RepresentationDeclaration? representation,
^^^^^^^^^^^^^^^^^^^^^^^^^
I solved this problem already. In case you're having the same issue, you just have to invoke the following commands.
flutter pub run build_runner clean
then rerun the
flutter pub run build_runner build --delete-conflicting-outputs
It solve my problem.