We all know that, we need a different fonts to use in App for better design for this we can use it in two different ways.
- declaring a font as part of an app.
- declare a font as part of a separate package
It is better to declare a font as part of a separate package Rather than declaring a font as part of an app. This is a convenient way to share the same font across several different projects, or for coders publishing their packages.
Follow the below steps for Exporting Fonts From A Package in Flutter App:
- Add a font to a package
- Add the package and font to the app
- Use the font
Adding fonts to a package:
If you want to export a font from a package, for this we need to import the font files into the lib
folder of the package project. Place font files directly in the lib
folder or in a sub directory, such as lib/fonts
.
In this tutorial, We are creating a awesome_package
with fonts placed in a lib/fonts
folder.