yii.
← Writing
開發筆記 · · 1 min read

Flutter | Image圖片的使用方式

這篇寫於 2019 年。工具和 API 變化很快,部分步驟可能已經不適用。

持續的學習紀錄

存取「本地」圖片#

AssetImage(路徑字串)

撰寫代碼之前需要做一下設定,打開 pubspec.yaml 檔案

在 uses-material-design 下方加入 assets 區塊(縮排需固定兩個空白)

  1. 匯入「檔案路徑」,指定讀取某個檔
  2. 匯入「資料夾路徑」,讀取資料夾裡的所有檔案
  • 使用

存取「網路」圖片#

NetworkImage(網址)
  • 使用

本文原刊登於 Medium。