如何更改 Flutter 应用程序的默认字体系列 [英] How to change the default font family of a Flutter app

查看:40
本文介绍了如何更改 Flutter 应用程序的默认字体系列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改应用程序的每个文本以使用特定字体?我可以使用 TextStyle() 单独更改它们,但是如何使我的应用程序默认为特定字体?你能告诉我怎么做吗?

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?

推荐答案

您可以按照以下步骤更改 Flutter 应用的默认字体系列:

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

1.将您的字体文件添加到您的项目文件夹中.Project Folder >资产字体 >后.

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

2.在项目的 pubspec.yaml 文件中使用带有样式的字体文件将字体系列声明为(示例):

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

  1. 在主类文件的 MaterialApp 小部件中,将默认字体系列定义为:
  1. In the MaterialApp widget of your main class file, define the default font family as:

这篇关于如何更改 Flutter 应用程序的默认字体系列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆