Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

build_runner showing error The getter 'macroKeyword' isn't defined for the class 'ClassDeclaration'

When I am running build_runner command it is showing me following error:

Failed to build build_runner:build_runner:
../../.pub-cache/hosted/pub.dev/dart_style-2.3.5/lib/src/front_end/ast_node_visitor.dart:251:16: Error: The getter 'macroKeyword' isn't defined for the class 'ClassDeclaration'.
  - 'ClassDeclaration' is from 'package:analyzer/src/dart/ast/ast.dart' ('../../.pub-cache/hosted/pub.dev/analyzer-6.2.0/lib/src/dart/ast/ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'macroKeyword'.
          node.macroKeyword,
                ^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dev/dart_style-2.3.5/lib/src/source_visitor.dart:595:19: Error: The getter 'macroKeyword' isn't defined for the class 'ClassDeclaration'.
  - 'ClassDeclaration' is from 'package:analyzer/src/dart/ast/ast.dart' ('../../.pub-cache/hosted/pub.dev/analyzer-6.2.0/lib/src/dart/ast/ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'macroKeyword'.
    modifier(node.macroKeyword);
                  ^^^^^^^^^^^^
like image 762
Code Hunter Avatar asked Feb 04 '26 20:02

Code Hunter


1 Answers

TL;DR: Upgrade your packages again and you should get a fixed dart_style.

Hi, it's me. I'm the problem.

A while back, I added support to dart_style for formatting (currently experimental) code using the upcoming macro keyword. When I did that, I forgot to update the analyzer constraint to ensure that dart_style only uses versions of the analyzer that have ClassDeclaration.macroKeyword in its public API.

Then I published dart_style 2.3.5 yesterday with that use of macroKeyword and the bad analyzer constraint. Oops. :(

I just published a new 2.3.6 version of dart_style which has the same analyzer constraint but doesn't have a compile error on macroKeyword. Since it uses the same analyzer constraint, anyone on the old broken 2.3.5 version of dart_style should be able to upgrade to the fixed version by running dart pub upgrade (or flutter pub upgrade or however else you generally upgrade your packages).

Sorry for the pain.

like image 100
munificent Avatar answered Feb 06 '26 10:02

munificent