Learn to Change Fonts in Flutter

ariba.dev
2 min readApr 17, 2023

In Flutter, you can easily change the font used in your app by specifying a custom font family. Here are the steps to do so:

  1. Find a font that you want to use in your app. You can download free fonts from websites such as Google Fonts or fontsquirrel.com.
  2. Add the font files to your project. You can create a new directory in your project called “fonts” and add the font files to that directory.
  3. Update your pubspec.yaml file to include the new font files. Add the following lines under the “flutter” section:
fonts:
- family: <font-family-name>
fonts:
- asset: fonts/<font-file-name>.ttf

Replace <font-family-name> with a name for your custom font family, and <font-file-name> with the name of the font file you added to your project.

4. Use the new font in your app. You can use the TextStyle class to specify a font family for your text. For example, you can set the font family for a Text widget like this:

Text(
'Hello, world!',
style: TextStyle(
fontFamily: '<font-family-name>',
fontSize: 20,
),
)

Replace <font-family-name> with the name of the font family you specified in your pubspec.yaml file.

That’s it! You should now be able to use your custom font in your Flutter app.

STAY TUNED FOR MORE AMAZING CONTENT

https://twitter.com/ariba_hussain10
https://www.linkedin.com/in/ariba1039/
https://instagram.com/ariba.dev

--

--

ariba.dev

⚡Dart makes my heart Flutter 💙🧑‍💻 • ✨ Software developer🧑‍💻 • Looking for the best remote opportunity in EUROPE