How to use Google Fonts and Text Themes in Flutter

Stop letting your Flutter projects look like everyone else's! What's the easiest way to fix it you may ask? Fonts. They're such a simple form of customization but they can go a long way in helping an app or a website feel different than the norm. Luckily, Flutter makes it really easy to use Google Fonts, the king of free, open source font hosting.

The process is fairly straight forward.

  1. Add the Google Fonts plugin to your pubspec.yaml file
  2. Use the Material Text Scaling tool and select the Google Fonts you'd like to use.
  3. Switch over to the 'code' tab inside the tool and select Flutter in the dropdown
  4. Paste the dart code into your main.dart file
  5. Import the google_fonts plugin to your main.dart

Your main.dart file should look something like this

That's it! Now you can use your TextTheme data wherever you'd like in your app