跳到主要內容

asset_path_not_string

資產路徑必須是檔案路徑(字串)。

描述

#

當資產對映包含非字串的 path 值時,分析器會產生此診斷資訊。

示例

#

以下程式碼會產生此診斷資訊,因為資產對映包含一個列表型別的 path

yaml
name: example
flutter:
  assets:
    - path: [one, two, three]
      flavors:
      - premium

常見修復

#

更改 asset 對映,使其包含一個字串型別的 path 值(一個有效的 POSIX 風格檔案路徑)

yaml
name: example
flutter:
  assets:
    - path: image.gif
      flavors:
      - premium