flutter-web:build_runner getter 'typeArguments' 没有为类'Annotation' 错误定义

时间:2021-03-08 08:47:41

标签: flutter flutter-web

在我的 web flutter 项目中,我正在尝试构建它:

flutter  packages pub run build_runner build --delete-conflicting-outputs

但我不知道为什么会出现此错误:

Failed to precompile build_runner:build_runner:
../../../Sdk/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 'Annotation'.
 - 'Annotation' is from 'package:analyzer/dart/ast/ast.dart' ('../../../Sdk/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.40.4/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);

我确定之前没问题,analyzer-0.40.4 没问题,但随着分析仪的更换,我仍然收到此错误。我使用的是 SDK 版本 2.7.0:

environment:
  sdk: ">=2.7.0 <3.0.0"

dependency_overrides:
  analyzer: 0.40.4
  build_resolvers: '1.4.4'

这是颤振医生:

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.24.0-10.2.pre, on Linux, locale en_US.UTF-8)                                                                                                                                                                                      [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.54.1)
[✓] Connected device (2 available)

• No issues found!

我还没有迁移到新的 Flutter 版本。

1 个答案:

答案 0 :(得分:0)

我不知道它是否有用但我终于解决了这个问题,我提出了我的解决方案可能会帮助一些人:

这就是所有的变化:

dependency_overrides:
  # analyzer: 0.40.4  // comment this
  build_resolvers: '1.4.2' // this

dev_dependencies:
  flutter_localizations:
    sdk: flutter
  build_runner: 1.10.4 // this