这是.YML文件中的代码
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- Images/
fonts:
- family: Pacifico
fonts:
- asset: Fonts/Pacifico-Regular.ttf
这是我在失去连接和崩溃之前添加的部分。
Text(
'Abdulrahman Hejazi',
style: TextStyle(
fontSize: 25,
color: Colors.white,
fontWeight: FontWeight.bold,
fontFamily: 'Pacifico'
),
),
我注意到,如果我从一开始就构建(运行(项目,它会崩溃,但如果我重新加载它,它会正常工作。
您需要将资产文件夹Fonts
重命名为小写fonts
,因为文件夹名称中不允许使用大写字母
它可能是以下任意一种:
- 字体文件名上有空格。如果是,请将其删除
- 您的字体文件名可能拼写错误
- 您的字体文件可能已损坏。尝试添加新的
PS。它是在热重新加载时加载字体,还是不加载?