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.
- Add the Google Fonts plugin to your pubspec.yaml file
- Use the Material Text Scaling tool and select the Google Fonts you'd like to use.
- Switch over to the 'code' tab inside the tool and select Flutter in the dropdown
- Paste the dart code into your main.dart file
- 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