Adding the custom fonts in Flutter
For download the fonts, use google fonts. you can get huge collection of fonts here.
Create the folder under your project:
Example:
flutter_project -> File -> New -> Directory -> create the directory named as "fonts".
paste the fonts, which you download from google fonts or other sources.
rename the fonts, It makes you easier name to remember, If you want. Just optional.
As I'm already informed you pubspec.yaml is manifest for the flutter projects.
Go to pubspec.yaml
write the following example code:
flutter:
uses-material-design: true
assets:
- images/
fonts:
- family: serif
fonts:
- asset: fonts/serif-regular.ttf
- family: arial
fonts:
- asset: fonts/arial-bold.ttf
Afterwards, don't forget to do packages upgrade and packages get.
then in your text widget,
Text("I'm right here",
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
fontFamily: 'arial',
color: Colors.white)),
Create the folder under your project:
Example:
flutter_project -> File -> New -> Directory -> create the directory named as "fonts".
paste the fonts, which you download from google fonts or other sources.
rename the fonts, It makes you easier name to remember, If you want. Just optional.
As I'm already informed you pubspec.yaml is manifest for the flutter projects.
Go to pubspec.yaml
write the following example code:
flutter:
uses-material-design: true
assets:
- images/
fonts:
- family: serif
fonts:
- asset: fonts/serif-regular.ttf
- family: arial
fonts:
- asset: fonts/arial-bold.ttf
Afterwards, don't forget to do packages upgrade and packages get.
then in your text widget,
Text("I'm right here",
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
fontFamily: 'arial',
color: Colors.white)),
Comments