flutter pub run build_runner 构建不起作用

Aym*_*che 12 dart dart-pub flutter dart-null-safety flutter-hive

运行 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;
Run Code Online (Sandbox Code Playgroud)

Maj*_*jid 22

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

运行一下flutter pub upgrade,应该可以了!


小智 8

dependency_overrides:
  watcher: ^1.1.0
Run Code Online (Sandbox Code Playgroud)

pubspec.yaml如果您面临以下情况,请添加这两行:

“‘FileSystemEvent’类无法在其库外部扩展、实现或混合,因为它是一个密封类。abstract class _ConstructableFileSystemEvent Implements FileSystemEvent { ”