Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter pub run build_runner build not working

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;
like image 399
Aymen Ziouche Avatar asked Dec 05 '25 05:12

Aymen Ziouche


2 Answers

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

Run flutter pub upgrade and it should work!

like image 55
Majid Avatar answered Dec 07 '25 22:12

Majid


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 { "

like image 33
Padmanava Karmakar Avatar answered Dec 07 '25 20:12

Padmanava Karmakar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!