This is a repost of an answer I wrote on Stack Overflow.
In this brief article I’ll give you the steps to include your own font in your Flutter project.
1. Add a font to your project
- Right click on your project folder and go to New > Directory. Call it
assets. It should be in your projects root directory.
- Copy and paste your font into the new
assetsdirectory. I'm just using a single font in my example, the regular dancing script font. I renamed it to
2. Register the font
- Open your pubspec.yaml file.
- Add the fonts info under the
fluttersection. Indentation is mandatory.
- family: DancingScript
- asset: assets/dancing_script.ttf
3. Use the font in your theme or widget
- Now you can use your font by setting the
fontFamilyattribute in the
TextStylewidget to whatever you called it in pubspec.yaml. For this example, I called it
4. Restart your app
- Whenever I add assets I find I need to do a full stop and restart. Otherwise I get errors.
- Read the documentation for more help.