Reputation: 14771
I am using Android Studio as my IDE. Now, I am trying to use custom fonts. But my code is not working. Here is what I have done so far. I download the fonts from the fonts.google.com and imported the TTF
files into my project creating a new folder called fonts right under my project root folder.
Then I added the following code to my pubspec.yml file.
fonts:
- family: Roboto
fonts:
- asset: fonts/Roboto-Regular.ttf
- asset: fonts/Roboto-Bold.ttf
weight: 400
Then I set the custom font to the Text widget as follows.
Text("Flight", textDirection: TextDirection.ltr,style: TextStyle(fontSize: 40.0, color: Colors.white, fontFamily: "Roboto", fontWeight: FontWeight.w400),)
When I launch the app, it does not work. The font is not changed. What is wrong with my code and how can I fix it?
Upvotes: 0
Views: 113
Reputation: 441
After adding the code in pubspec.yml, you should run flutter pub get
in the terminal. This command gets all the dependencies listed in the pubspec.yaml
Upvotes: 1