set google font as default in a flutter app

Set a Google font as default in Flutter

In one of the mobile app I’m curently working on, I needed to use a google font as default in my theme data. Here is a simple way to set Nunito Google font (or any else Google Font you wanna use) as default font in the theme of your Flutter app.

First, define the family and styles you’ll need. In my case, I needed 5 styles, from light to extra-bold. Download the font from the official google font website here.

Nunito google font preview
Nunito Google Font, selected in 6 different styles

Then, unzip the selected files in the asset folder of your project, and add the path to these files in the pubspec.yaml file, like this :

code snippet
Add the font to your pubspec.yaml file

Finally, add the font family in your theme file :

code snippet
Add the font family in your theme file

And that’s it, your app is now using the Nunito GoogleFont as default.

Elya

Hi ! I'm a junior web developper and UX designer. Living in France, mother of 2, bookworm, cats lover, JS girl, yada yada yada. The usual stuff. Let's talk about code !

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

back to top