How to Add Fonts in Flutter?

Fonts are one of the most important aspects of any app. Presentation requires the use of easy-to-read fonts. Your text will be more valuable because of the fonts. It aids readers’ comprehension of text material. The right combination of color, font, and text size might help you attract your target audience. In this blog, you’ll learn how to use the following methods to add your selected fonts to your project:

  • Download the .ttf file of your desired font.
  • Go to your project directory and create “assets” folder.
  • Move your font file to the assets folder that you created.
  • Open pubspec.yaml and enter this code:
fonts:
    - family: "Name of your desired font"
      fonts:
        - asset: assets/"insertyourfilename".ttf
  • Finally, you can use now your desired font by following this example code:
Text ('Your New Font',
style: TextStyle(
fontFamily: 'Name of your desired font'
),)

Leave a Comment

Your email address will not be published. Required fields are marked *