How to use custom fonts in Flutter?
The default font used in Flutter is Roboto. If you want to add a custom font in Flutter, you have 2 ways. If the font you want to add is available in Google Fonts, you can use google_fonts package available in Dart Pub. If the font you want to use is not available in Google fonts, you must add a TTF file of the font to assets and load it using pubspec.yaml. Both methods are described in the following tutorial.
1. Using google_fonts Package
Add google_fonts to pubspec.yaml as shown in below. There are no other configurations required for the plugin on both iOS and Android operating systems.
google_fonts package can be used to apply any desired font available on google fonts both as TextStyle of a Text() widget and inside the Theme() widget. Both the examples are shown below.
2. Adding fonts not available in Google fonts
Add TTF file of the font to assets
The first step is to get the TTF file of the font you would like to use and add it to the assets of your app. The folder structure is shown in the image below.
Add font to pubspec.yaml
Now we need to add the font to pubspec.yaml as shown below. This will load the font for usage inside our app.
Example usage of the font both as style of a Text() widget.
Shared Preferences in Flutter tutorial
Step by step instructions on how to install, configure and use shared preference feature using shared_preferences plugin in Flutter
Polygon clipper in Flutter
A guide on how to clip images in various polygon shapes using polygon_clipper in Flutter
How to do hero animation in Flutter?
Step by step guide on how to do hero animation in Flutter