flutterbuild-runner

Failed to precompile build_runner:build_runner:


I created a new project, added dependencies when I launch it flutter pub run build_runner build I get:

/C:/Users/Michael/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:1600:40: Error: Getter not found: 'topLevelVariable'.
      return kinds.contains(TargetKind.topLevelVariable);
                                       ^^^^^^^^^^^^^^^^
/C:/Users/Michael/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:2024:23: Error: Getter not found: 'topLevelVariable'.
      case TargetKind.topLevelVariable:
                      ^^^^^^^^^^^^^^^^
/C:/Users/Michael/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:2024:23: Error: Type 'dynamic' of the case expression is not a subtype of type 'TargetKind' of this switch
 expression.
 - 'TargetKind' is from 'package:meta/meta_meta.dart' ('/C:/Users/Michael/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/meta-1.3.0/lib/meta_meta.dart').
      case TargetKind.topLevelVariable:
                      ^
/C:/Users/Michael/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:2001:13: Context: The switch expression is here.
    switch (this) {
            ^
pub finished with exit code 1

I've read everything on stackoverflow, but I haven't found a solution. Any idea?


Solution

  • Specify the analyzer version

    analyzer: 1.5.0
    

    Warning: do not up to the latest version, because it depends on meta package as is flutter_test - where you can't specify the version