Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the default font family of a Flutter app

How can I change every text of my app to use a specific font? I can change them individually by using the TextStyle() but how can I make my app default to a specific font? Can you show me how?

like image 934
Hussein Al-Mosawi Avatar asked Oct 07 '20 04:10

Hussein Al-Mosawi


People also ask

What is default font family in Flutter?

The default font of MaterialApp is roboto , a Google font.

How do you change the font in Flutter code?

Text( 'Home', style: TextStyle( fontWeight: FontWeight. w300, // light fontStyle: FontStyle. italic, // italic ), );


1 Answers

You can change the default font family of your Flutter app by following the below steps:

1. Add your font files into your project folder. Say Project Folder > assets > fonts > hind.

2. Declare the font family with font files with style in your project's pubspec.yaml file as (An example):

enter image description here

  1. In the MaterialApp widget of your main class file, define the default font family as:

enter image description here

like image 74
OMi Shah Avatar answered Sep 19 '22 14:09

OMi Shah