'Failed to build build_runner:build_runner:Try using an explicit extension application of the wanted extension or hiding unwanted extensions from scope
I can not use flutter pub run build_runner watch --delete-confilicting-output to generate freezed file. the error is:
Failed to build build_runner:build_runner:
/C:/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' ('/C:/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.
^^^^^^^^^^^^^
/C:/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 {
^^^^^^^^^^^^^
/C:/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 {
^^^^^^^^^^^^^
/C:/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'.
-- '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;
yaml file is:
environment:
sdk: ">=2.14.3 <3.0.0"
dependencies:
flutter:
sdk: flutter
google_maps_flutter: ^2.1.1
location: ^4.3.0
firebase_core: ^1.10.0
cloud_firestore: ^3.1.0
flutter_bloc: ^8.0.0
bloc: ^8.0.0
freezed: ^0.12.7
dartz: ^0.10.0
freezed_annotation: ^1.0.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0
build_runner:
analyzer:
# ^1.12.2
freezed:
#^1.12.0
Solution 1:[1]
For all 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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Manishyadav |
