flutter Unable to load asset: assets/images/IMG_3258.jpg

在添加圖片應(yīng)用時(shí),不能將圖片像Ios一樣直接添加上去,否側(cè)就會(huì)報(bào)如下的錯(cuò)誤。

flutter Unable to load asset: assets/images/IMG_3258.jpg

1.在根目錄下創(chuàng)建assets文件夾

2.在assets下創(chuàng)建images文件夾,將IMG_3258.jpg圖片放入

3.在pubspec.yml 中添加上,如下圖所示。

如圖所示.png

4,調(diào)用方法

      Widget _startTextViewLine(BuildContext context){ return new ListView(
children: <Widget>[
  new Image.asset(
    'assets/images/IMG_3258.jpg',
    width: 320,
    height: 260,
    fit: BoxFit.cover,
 //        color: Colors.orange,

  ),

],
);

}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容