Flutter Build_Runner 生成楼层时构建失败

问题描述 投票:0回答:3

flutter 升级后构建失败。

$ flutter pub run build_runner build
[INFO] Generating build script completed, took 331ms

[WARNING] ../../.pub-cache/hosted/pub.dev/floor_generator-1.4.1/lib/misc/type_utils.dart:25:26: Error: The getter 'element' isn't defined for the class 'DartType'.
 - 'DartType' is from 'package:analyzer/dart/element/type.dart' ('../../.pub-cache/hosted/pub.dev/analyzer-5.0.0/lib/dart/element/type.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
  bool get isEnumType => element is EnumElement;

如何解决?

形成 pubspec.yaml:

地板生成器:^1.4.1

build_runner:^2.1.2

flutter build-runner flutter-floor
3个回答
0
投票

确保在 flutter 升级后运行

flutter pub get
。然后
flutter pub cache repair


0
投票

我通过向 pubspec.yaml 添加一行来修复此错误

dependency_overrides:
  analyzer: ^5.4.0

0
投票

使用最新的 flutter 版本,您可以看到错误,然后按照以下步骤操作:

  1. 删除了 pubspec.lock
  2. 运行 flutter pub get,它会再次安装依赖项运行 flutter pub run build_runner build --delete-conflicting-outputs。

此错误之后应该消失了。

© www.soinside.com 2019 - 2024. All rights reserved.