【问题标题】:Unable to locate asset entry in pubspec.yaml. (font)无法在 pubspec.yaml 中找到资产条目。 (字体)
【发布时间】:2019-08-29 20:48:47
【问题描述】:

我正在尝试在颤振中使用自定义字体。我已将字体放在根目录的“fonts”文件夹中,与我的 pubspec.yaml 文件处于同一级别

我还使用文档中的格式将字体添加到我的 pubspec.yaml 中。完整文件:

name: app_name
description: app_description

version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter




  cupertino_icons: ^0.1.2
  rxdart: ^0.22.1+1
  intl: ^0.15.7



dev_dependencies:
  flutter_launcher_icons: "^0.7.2"
  flutter_test:
    sdk: flutter




flutter:
  fonts:
    - family: Lato
      fonts:
        - asset: /fonts/Lato-Regular.ttf


flutter_icons:
  ios: true
  android: true
  image_path_ios: "lib/res/launcher/ic_launcher_iphone.png"
  image_path_android: "lib/res/launcher/ic_launcher.png"

我仍然收到上述错误

Error: unable to locate asset entry in pubspec.yaml: "/fonts/Lato-Regular.ttf".

【问题讨论】:

    标签: flutter


    【解决方案1】:

    删除前导/asset: /fonts/Lato-Regular.ttf -> asset: fonts/Lato-Regular.ttf

    确保您的字体文件夹位于项目的顶层文件夹中。

    【讨论】:

    • 哇。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-10
    • 2021-08-31
    • 1970-01-01
    • 1970-01-01
    • 2021-07-02
    • 2016-05-15
    相关资源
    最近更新 更多