Search code examples
flutterdartpubspec.yaml

Flutter error on custom font : 'Error on line 78, column 4: Expected a key while parsing a block mapping.' in pubspec.yaml


i'm new to flutter and I face a new error when i was trying use a custome font. I see the official docs and even try to copy the codes structure from there, but it doesn't work either. here is the error : "Error on line 78, column 4: Expected a key while parsing a block mapping." and here is screenshot of error:[custom font error]

I try to indent thr lines in pubspec.yaml but still dont work.

and here is my pubspec.yaml file :

# "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  fonts:
    - family: OpenSans
      fonts:
        - asset: fonts/OpenSans-Regular.ttf
        - asset: fonts/OpenSans-Bold.ttf
          weight: 700
    - family: Quicksand
      fonts:
        - asset: fonts/Quicksand-Regular.ttf
        - asset: fonts/Quicksand-Bold.ttf
          weight: 700
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #

and here is screenshot of my pubspec.yaml file with more details: pubspec.yaml screenshot

any help will be appriaciated.


Solution

  • I found the Problem. the problem was with the folder address of my fonts. i wrote the the wrong address for fonts in pubspec.yaml file.