flutter 我想将此字体添加到资源

ajsxfq5m  于 2023-01-27  发布在  Flutter
关注(0)|答案(3)|浏览(117)

assets:
   - assets/
       
   fonts:
     - family: Schyler
       fonts:
        - asset: fonts/Schyler-Regular.ttf
        - asset: fonts/Schyler-Italic.ttf
  
    - family: Trajan Pro
      fonts:
        - asset: fonts/TrajanPro.ttf
        - asset: fonts/TrajanPro_Bold.ttf
         weight: 700

我想将此字体添加到资源

kfgdxczn

kfgdxczn1#

你的缩进是不正确的pubspec.yaml是给错误当你有错误的缩进在它给予一个制表符空格之前

fonts:

查看此屏幕截图,并像

这样进行缩进

uoifb46i

uoifb46i2#

更有可能的是整个块的缩进是错误的(或缺失的)。
读取下面的link

pqwbnv8z

pqwbnv8z3#

尝试按照flutter的精确缩进

# The following section is specific to Flutter packages.
flutter:
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/

  fonts:
    - family: Schyler
      fonts:
        - asset: fonts/TrajanPro.ttf
        - asset: fonts/TrajanPro_Bold.ttf
          weight: 700

这里每个点表示单个空格

查看更多关于adding assets-and-images的信息。

相关问题