簡體   English   中英

我正在嘗試運行我的應用程序,並且收到此錯誤消息?

[英]i am trying to run my app and i am getting this error message?

我在android studio中使用flutter。 我所有的Dart文件都沒有錯誤,我的圖像文件中有一個名為avatar.png的頭像圖像,但出現此錯誤:

找不到資產的文件或變體:images / avatar.png。

我的圖像文件不在正確的文件夾中嗎? 如果是,我應該將其粘貼到我的應用項目文件中嗎?

撲:

uses-material-design: true
# To add assets to your application,
# add an assets section,
# like this: assets: -images / avatar.png# - images / a_dot_ham.jpeg
Widget logo() {
    return new Hero(
        tag: 'hero',
        child: new CircleAvatar(
            backgroundColor: Colors.blue,
            radius: 80.0,
            child: Image.asset('images/avatar.png'),
        ),
    );
}

在pubspec.yaml中檢測到錯誤:找不到資產:images / avatar.png的文件或變體。

錯誤:無法建立資產捆綁

您是否看過Flutter文檔中的圖像

您要將所有資源(例如, images )放在根目錄下的assets (在您的情況下為images )文件夾中,並在pubspec.yaml文件中指定它。

還要看一下Image構造函數。

請檢查Assets文件夾中的Avtar.png文件,認為您忘記或刪除了該文件。

塊報價

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM