Adding the custom fonts in Flutter

For download the fonts, use google fonts. you can get huge collection of fonts here.

Create the folder under your project:

Example:

flutter_project -> File -> New -> Directory -> create the directory named as "fonts".

paste the fonts, which you download from google fonts or other sources.

rename the fonts, It makes you easier name to remember, If you want. Just optional.

As I'm already informed you pubspec.yaml is manifest for the flutter projects.

Go to pubspec.yaml

write the following example code:

flutter:
  uses-material-design: true
  assets:
    - images/
  fonts:
    - family: serif
      fonts:
        - asset: fonts/serif-regular.ttf
    - family: arial
      fonts:
        - asset: fonts/arial-bold.ttf

Afterwards, don't forget to do packages upgrade and packages get.

then in your text widget,

Text("I'm right here",
                style: TextStyle(
                    fontSize: 22,
                    fontWeight: FontWeight.bold,
                    fontFamily: 'arial',
                    color: Colors.white)),

Comments

Popular posts from this blog

Flutter Bloc - Clean Architecture

What's new in android 14?

Dependencies vs Dev Dependencies in Flutter