• 카테고리

    질문 & 답변
  • 세부 분야

    모바일 앱 개발

  • 해결 여부

    해결됨

.g 파일이 안생기네요

24.02.07 13:04 작성 조회수 261

0

flutter pub run build_runner build 터미널에서 실행

터미널창 내용


PS E:\_flutter\section24_calendar> flutter pub run build_runner build
Deprecated. Use `dart run` instead.
Building package executable... (6.4s)
Built build_runner:build_runner.
[INFO] Generating build script completed, took 352ms
[INFO] Precompiling build script... completed, took 7.4s
[INFO] Building new asset graph completed, took 994ms
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms
[INFO] Generating SDK summary completed, took 4.2s
[WARNING] drift_dev on lib/database/drift_database.dart:
Could not resolve Dart library package:section24_calendar/database/drift_database.dart
This builder requires Dart inputs without syntax errors.
However, package:section24_calendar/database/drift_database.dart (or an existing part) contains the following errors.
drift_database.dart:24:1: A function body must be provided.

Try fixing the errors and re-running the build.

[WARNING] drift_dev on lib/database/drift_database.dart:
Could not resolve Dart library package:section24_calendar/database/drift_database.dart
This builder requires Dart inputs without syntax errors.
However, package:section24_calendar/database/drift_database.dart (or an existing part) contains the following errors.
drift_database.dart:24:1: A function body must be provided.

Try fixing the errors and re-running the build.

[INFO] Running build completed, took 14.4s
[INFO] Caching finalized dependency graph completed, took 75ms
[INFO] Succeeded after 14.5s with 68 outputs (158 actions)
PS E:\_flutter\section24_calendar>

[INFO] Succeeded after 14.5s with 68 outputs (158 actions)

라고 68개 생긴다고 나오는데

 

마우스 우클릭 해도 파일은 안생김


 

검색해보니

flutter pub add --dev drift_dev

flutter pub run build_runner clean

flutter pub run build_runner build --delete-conflicting-outputs

각각 해봐도 안생기네요

flutter pub add --dev drift_dev  해봄

PS E:\_flutter\section24_calendar> flutter pub add --dev drift_dev
"drift_dev" is already in "dev_dependencies". Will try to update the constraint.
Resolving dependencies... 
  _fe_analyzer_shared 64.0.0 (67.0.0 available)
  analyzer 6.2.0 (6.4.1 available)
  ffi 2.1.0 (2.1.2 available)
  flutter_lints 2.0.3 (3.0.1 available)
  intl 0.18.1 (0.19.0 available)
  js 0.6.7 (0.7.0 available)
  lints 2.1.1 (3.0.0 available)
  matcher 0.12.16 (0.12.16+1 available)
  material_color_utilities 0.5.0 (0.8.0 available)
  meta 1.10.0 (1.12.0 available)
! path 1.9.0 (overridden)
  test_api 0.6.1 (0.7.0 available)
  web 0.3.0 (0.4.2 available)
  web_socket_channel 2.4.0 (2.4.3 available)
Got dependencies!
13 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
PS E:\_flutter\section24_calendar>
flutter pub run build_runner clean   해봄


PS E:\_flutter\section24_calendar> flutter pub run build_runner clean
Deprecated. Use `dart run` instead.
Building package executable... (6.3s)
Built build_runner:build_runner.
[WARNING] Deleting cache and generated source files.
This shouldn't be necessary for most applications, unless you have made intentional edits to generated files (i.e. for testing). Consider filing a bug at https://github.com
/dart-lang/build/issues/new if you are using this to work around an apparent (and reproducible) bug.
[WARNING] No asset graph found. Skipping cleanup of generated files in source directories.
[INFO] Cleaning up source outputs completed, took 1ms
[INFO] Cleaning up cache directory completed, took 37ms
PS E:\_flutter\section24_calendar>

flutter pub run build_runner build --delete-conflicting-outputs  해봄


PS E:\_flutter\section24_calendar> flutter pub run build_runner build --delete-conflicting-outputs
Deprecated. Use `dart run` instead.
[INFO] Generating build script completed, took 335ms
[INFO] Reading cached asset graph completed, took 100ms
[INFO] Checking for updates since last build completed, took 911ms
[INFO] Running build completed, took 17ms
[INFO] Caching finalized dependency graph completed, took 78ms
[INFO] Succeeded after 102ms with 0 outputs (0 actions)
PS E:\_flutter\section24_calendar>

 

어찌 해야 조을까요

 

답변 2

·

답변을 작성해보세요.

0

cdway님의 프로필

cdway

질문자

2024.02.07

해결했습니다.

2개 오타가 있었네요

24번 라인 ; 빼먹구

29라인 함수이름에서 s 가 빠졌네요.

AI 인턴이 잘하네요

 

 

 

0

인프런 AI 인턴님의 프로필

인프런 AI 인턴

2024.02.07

안녕하세요, 인프런 AI 인턴입니다.

cdway님의 .g.dart 파일 생성 문제는 Flutter 프로젝트에서 보통 code generation 프로세스 중에 발생하는 일반적인 문제 중 하나입니다. 지식공유자의 이전 답변 중에서 구체적으로 동일한 에러 메시지나 상황에 대한 정확한 해결책을 말해주는 것을 찾지 못했으나, 비슷한 상황에서 발생하는 문제와 그 해결 방안들을 참조할 수 있습니다.

다음은 일반적인 .g.dart 파일 생성과 관련된 문제를 설명하는 인프런 내의 기존 답변입니다:

  1. hive generate써서 g.dart 파일 만드는게 안됩니다.

    • 이 답변에서는 stat_model.dart 파일에 문제가 있는지 확인하라고 조언합니다. 코드 생성 도구는 에러가 없는 Dart 코드가 필요하기 때문에, 정확한 구문과 주석(annotation)들을 확인해야 코드 생성이 작동한다고 언급됩니다.
  2. 섹션24 데이터베이스

    • 지식공유자는 다시 한 번 패키지 버전에 문제가 없는지 확인하라고 권장합니다. 만약 버전에 문제가 없다면 일부 외부 지원을 요청하도록 안내합니다.

cdway님의 경우, 터미널 출력에 주목하여 문제의 원인을 찾아보는 것이 좋습니다. 특히, drift_database.dart:24:1: A function body must be provided.라는 메시지는 drift_database.dart 파일에 구문 오류가 있음을 나타냅니다. 오류 메시지에 따르면 24번 라인에 함수 본문이 없어서 문제가 발생하고 있습니다.

따라서 .g.dart 파일 생성 문제를 해결하기 위해 다음 사항을 확인해야 합니다:

  • drift_database.dart 파일의 24번 라인에 함수 본문이 제대로 제공되었는지 확인합니다.
  • 모든 필요한 주석(annotation)이 있는지, 그리고 다른 구문 상의 오류가 없는지 확인합니다.
  • 코드 생성 도구는 오류 없이 컴파일 가능한 Dart 소스 코드를 필요로 하기 때문에, 코드에 오류가 없도록 해야 합니다.

에러 메시지가 명확하게 얻어진 경우, 실제 에러 메시지를 해결한 후에 코드 생성을 다시 진행해보세요. 만약 이러한 절차로 해결되지 않거나, 추가적인 질문이 생기면, 강의 페이지의 질문&답변 게시판에 자세한 상황을 설명하며 질문해주세요. 곧 지식공유자께서 답변해 주실 것입니다.

저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다.
현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏
추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요.