Here 3 steps to use the default custom font in Flutter apps.
1. Import the font files
Add your fonts to the assets folder.
Flutter supports the following font formats:
Flutter does not support
.woff2 fonts for all platforms.
2. Declare the font in the pubspec
Add the custom fonts in pubspec.yaml file. Each entry in this list should have a “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: Jomolhari fonts: - asset: assets/fonts/Jomolhari.ttf - family: DDC_Uchen fonts: - asset: assets/fonts/DDC_Uchen/DDC_Uchen.ttf
3. Set a font as the default
To use a font as the default, set the
fontFamily property as part of the app’s
theme. The value provided to
fontFamily must match the
family a name declared in the
pubspec.yaml. Your main method should look something like this:
Refer official document for more information.
Kuzu Zangpo la! I am Sonam Dargay. I am a full-time software developer. Apart from 9-5 office works, I am a tech enthusiast, blogger, and dreamer.
I graduated from the College of Science and Technology(CST), affiliated with the Royal University of Bhutan.