flutter pub run build_runner 构建不起作用

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

运行 flutter pub run build_runner build 时出现此错误。

Failed to build build_runner:build_runner:
../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.2/lib/src/error/best_practices_verifier.dart:258:50: Error: The property 'displayString' is defined in multiple extensions for 'TargetKind' and neither is more specific.
 - 'TargetKind' is from 'package:meta/meta_meta.dart' ('../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.7.0/lib/meta_meta.dart').
Try using an explicit extension application of the wanted extension or hiding unwanted extensions from scope.
        var kindNames = kinds.map((kind) => kind.displayString).toList()
                                                 ^^^^^^^^^^^^^
../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.2/lib/src/error/best_practices_verifier.dart:1950:14: Context: This is one of the extension members.
  String get displayString {
             ^^^^^^^^^^^^^
../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.7.0/lib/meta_meta.dart:91:14: Context: This is one of the extension members.
  String get displayString {
             ^^^^^^^^^^^^^
../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.2/lib/src/error/best_practices_verifier.dart:260:36: Error: The getter 'commaSeparatedWithOr' isn't defined for the class 'List<dynamic>'.
 - 'List' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'commaSeparatedWithOr'.
        var validKinds = kindNames.commaSeparatedWithOr;
flutter dart dart-pub dart-null-safety flutter-hive
3个回答
8
投票

这个问题很可能与过时的依赖项有关,我今天也遇到了类似的问题。

运行

flutter pub upgrade
,它应该可以工作!


1
投票

遇到此问题的人,只需覆盖

"meta"
依赖即可。

只需将这些行添加到 pubspec.yaml

dependency_overrides:
meta: 1.6.0

这可能会解决您的问题,并且 github 上有很好的讨论 https://github.com/dart-lang/sdk/issues/46687


0
投票

依赖覆盖: 观察者:^1.1.0

如果您遇到“类‘FileSystemEvent’无法在其库外部扩展、实现或混合,因为它是一个密封类”,请在 pubspec.yaml 中添加这两行。 抽象类 _ConstructableFileSystemEvent 实现 FileSystemEvent { ”

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