-
카테고리
-
세부 분야
모바일 앱 개발
-
해결 여부
미해결
Image.asset이 정상적으로 되지 않습니다.
23.08.22 11:37 작성 조회수 611
0
pubspec.yaml 에도 경로를 잘 지정했고,
사진파일이 잘못 되었나해서 바꿔가면서 시도해도 마찬가지로 아래와 같이 파일을 찾을 수 없다고 뜨네요.
답변을 작성해보세요.
1
오준석
지식공유자2023.08.22
pubspec.yaml 경로 지정할 때 들여쓰기 잘 되었나 확인 바랍니다.
들여쓰기는 무조건 공백 2칸 단위로 적용해야 합니다.
그리고 설정 후에 pub get 실행도 확인해 보시고요.
여전히 문제가 있다면 pubspec.yaml 파일에서 그림파일 경로 지정하는 부분 코드를 보여주시기 바랍니다.
0
kcontrol
질문자2023.08.22
공백을 2칸씩 변경해도 동일하게 파일을 못찾습니다ㅠ
pubsepc.yaml 파일은 아래와 같습니다.
# To add assets to your application, add an assets section, like this:
assets:
- assets/pic.jpg
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
에러 메세지는 하기와 같습니다.
======== Exception caught by image resource service ================================================
The following assertion was thrown resolving an image codec:
Unable to load asset: "assets/pic.jpg".
Exception: Asset not found
When the exception was thrown, this was the stack:
#0 PlatformAssetBundle.loadBuffer (package:flutter/src/services/asset_bundle.dart:372:7)
<asynchronous suspension>
#1 AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:811:18)
<asynchronous suspension>
Image provider: AssetImage(bundle: null, name: "assets/pic.jpg")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#f2583(), name: "assets/pic.jpg", scale: 1.0)
====================================================================================================
오준석
지식공유자2023.08.22
전혀 문제 없어 보입니다.
주의할 점이라면 물론 해 보셨겠지만 pubspec.yaml 을 수정했을 때는 pub get 실행 및 앱 완전 종료하고 재시작해야 반영 됩니다.
일단 안 되는 것 너무 오래 붙잡으면 힘만 드니까 다음으로 진행하시죠.
한숨 자고 일어나서 다시 보면 뭔가 보일 수 있습니다.
답변 2