getter 'typeArguments' 没有为类 'Annotation' 定义

时间:2021-03-10 14:26:03

标签: flutter dart

我今天更新了我的 flutter 并且 build_runner 没有工作得到这个(下面)错误 错误 - 当我运行 flutter pun run build_runner build 时 尝试了每个命令

扑干净| flutter pub 包升级 | Flutter pub 缓存修复 等但不工作

    dependencies:
      flutter:
        sdk: flutter
      ...
      ...
      flutter_svg: ^0.19.3
      xml: ^4.2.0
      build_resolvers: ^1.5.4
      build: ^1.6.3
      injectable_generator: ^1.2.0
      convert: ^3.0.0
      glob: ^2.0.0
    
    dev_dependencies:
      flutter_test:
        sdk: flutter
      built_value_generator: ^7.0.9
      json_serializable: ^4.0.2
      build_runner: ^1.11.5
      retrofit_generator: ^1.3.7+2
      mobx_codegen: ^1.1.0+1
    
    dependency_overrides:
      convert: ^3.0.0
      pedantic: ^1.9.0
      analyzer: ^0.41.2



Failed to precompile build_runner:build_runner:
../../flutter-dart/flutter/.pub-cache/hosted/pub.dartlang.org/dart_style-1.3.14/lib/src/source_visitor.dart:302:16: Error: The getter 'typeArguments' isn't defined for the class 'Annota
tion'.
 - 'Annotation' is from 'package:analyzer/dart/ast/ast.dart' ('../../flutter-dart/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.2/lib/dart/ast/ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'typeArguments'.
    visit(node.typeArguments);
               ^^^^^^^^^^^^^
pub finished with exit code 1

2 个答案:

答案 0 :(得分:5)

问题是 dart_style 包是使用最新分析器包的更新版本。

在dependency_overrides下降级dart_style版本:

dependency_overrides:
  dart_style: '>=1.3.13 <=1.3.13'

我对当前版本的 mobx_codegen (1.1.2) + 分析器 (0.41.1) 有同样的问题,这样做很有效。

答案 1 :(得分:1)

作为固定 dart-style 的替代方法,您还可以将分析器包固定到 0:41.1,这似乎也有效,并且可能没有固定样式的任何副作用。

dependency_overrides:
  analyzer: 0.41.1