Add fonts assets
Make a folder inside /assets
in the main app and then make another subfolder in assets named fonts
:
/assets
/fonts
Now put all the downloaded fonts inside the fonts folder as shown below:
/assets
/fonts
/Schyler-Regular.ttf
/Schyler-Italic.ttf
Register the font
- Open your
pubspec.yaml
file. - Add the fonts info under the
flutter
section. Indentation is mandatory.
fonts:
- family: Schyler
fonts:
- asset: fonts/Schyler-Regular.ttf
- asset: fonts/Schyler-Italic.ttf
style: italic
Set the font using fontFamily inside the Text widget as shown below:
Text(
'Hello world',
style: TextStyle(
fontFamily: 'Schyler',
),
)