18

when running flutter pub run build_runner build I get this error.

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;
1
  • update the version of build_runner it will be work fine Commented Feb 23, 2022 at 11:26

5 Answers 5

41

This issue is related to outdated dependencies most likely, I had a similar one just today.

Run flutter pub upgrade and it should work!

Sign up to request clarification or add additional context in comments.

1 Comment

In my case I executed dart pub upgrade and worked as well. Answer found here
17
dependency_overrides:
  watcher: ^1.1.0

Add these two lines in pubspec.yaml if you are facing:

"The class 'FileSystemEvent' can't be extended, implemented, or mixed in outside of its library because it's a sealed class. abstract class _ConstructableFileSystemEvent implements FileSystemEvent { "

3 Comments

This solution worked for me. Care to explain what's going on here?
In my case I added these lines but I also needed to add pub_semver: ^2.1.4 as an additional dependency override before the error was resolved.
It worked out for me, thanks. But why?
5

With latest flutter versions you can see the error then Follow below steps :

  1. Deleted pubspec.lock
  2. Run flutter pub get, it install dependencies again run flutter pub run build_runner build --delete-conflicting-outputs.

After this error should be gone.

Comments

3

dart pub upgrade will fix the problem

Comments

2

Those who are experiencing this problem, just overwrite the "meta" dependency.

just add these lines to pubspec.yaml

dependency_overrides:
meta: 1.6.0

This might solve your issue, and there is well discussed github discussion https://github.com/dart-lang/sdk/issues/46687

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.