dart flutter pub run build_runner build not working

x7rlezfr  于 2023-09-28  发布在  Flutter
关注(0)|答案(3)|浏览(177)

当运行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;
dgtucam1

dgtucam11#

这个问题很可能与过时的依赖关系有关,我今天遇到了一个类似的问题。
运行flutter pub upgrade,它应该工作!

cclgggtu

cclgggtu2#

遇到此问题的人,只需覆盖"meta"依赖项。
只需将这些行添加到pubspec.yaml

dependency_overrides:
meta: 1.6.0

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

azpvetkf

azpvetkf3#

dependency_overrides:监视器:^1.1.0
在pubspec.yaml中添加这两行,如果您遇到“Theclass 'FileSystemEvent' can 't be extended,implemented,or mixedinoutside of its library because it's a sealed class.抽象类_ConstructableFileSystemEvent实现FileSystemEvent {“

相关问题