Я получаю эту ошибку, когда пытаюсь запустить flutter pub run build_runner build. Последнее, что я помню, это изменение @JsonKey(name: "key") на одном из занятий по удаленному ответу. Я впервые получаю эту ошибку при запуске build_runner.
Что именно происходит в этом коде ошибки? И как это исправить?
(править)
Я использую Flutter версии 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,
^^^^^^^^^^^^^^^^^^^^^^^^^





Я уже решил эту проблему. Если у вас возникла та же проблема, вам просто нужно вызвать следующие команды.
flutter pub run build_runner clean
затем повторно запустите
flutter pub run build_runner build --delete-conflicting-outputs
Это решает мою проблему.
В моем случае это была проблема с версией анализатора, которая была в dependency_overrides в pubspec.yaml из-за этой проблемы
Но, похоже, проблема решена, поэтому после удаления анализатора переопределения зависимостей самой высокой версии решена проблема генерации кода build_runner.