Flutter 에서 build_runner 를 사용해 flutter pub run build_runner build 를 했을 때에, Failed to precompile build_runner:build_runner 와 같은 에러가 나오는 경우의 대응

환경



ProductName: Mac OS X
ProductVersion: 10.15.7
BuildVersion: 19H1030

Flutter: 2.2.0
build_runner: 2.0.2

오류 정보


$ flutter pub run build_runner build

Failed to precompile build_runner:build_runner:
../../../.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);
                                       ^^^^^^^^^^^^^^^^
../../../.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:
                      ^^^^^^^^^^^^^^^^
../../../.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' ('../../../.pub-cache/hosted/pub.dartlang.org/meta-1.3.0/lib/meta_meta.dart').
      case TargetKind.topLevelVariable:
                      ^
../../../.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

대응


$ flutter packages pub upgrade

vscode라면 아래를 클릭해도


참고

좋은 웹페이지 즐겨찾기