flutter 的 Google Fonts 包无法在发布模式下加载字体

Bal*_*esh 6 flutter flutter-dependencies

我在我的 flutter 应用程序中使用了 Google 字体包
https://pub.dev/packages/google_fonts

该应用程序在调试模式下运行良好,并且字体加载没有任何问题。

但是,当我在发布模式下构建并运行应用程序时,字体无法加载。大多数情况下,应用程序会崩溃,有时会加载默认的 Roboto 字体。

GitHub 上有一些未解决的问题,但其中任何一个都不能解决我的问题。我尝试清理构建文件夹,重新检查pubspec.yaml文件,检查google_fonts软件包版本,验证互联网连接,甚至重新创建项目。但没有解决这个问题。

版本:

google_fonts: ^1.1.0
Run Code Online (Sandbox Code Playgroud)

flutter run --release我在使用命令运行应用程序时收到此错误日志
这是我收到的错误:

I/flutter (17872): Error: google_fonts was unable to load font Montserrat-SemiBold because the following exception occured:
I/flutter (17872): Exception: Failed to load font with url: https://fonts.gstatic.com/s/a/5f82f6e55db43e905c6ab9d04395566b243c41798d6a53545ffbd10ed6c424c4.ttf
I/flutter (17872): Error: google_fonts was unable to load font Montserrat-Medium because the following exception occured:
I/flutter (17872): Exception: Failed to load font with url: https://fonts.gstatic.com/s/a/cec0f6e0bfbfaa352eb189f0eb220916dd278b02aaf824be87055ba5cc38d58b.ttf
I/flutter (17872): Error: google_fonts was unable to load font Montserrat-Regular because the following exception occured:
I/flutter (17872): Exception: Failed to load font with url: https://fonts.gstatic.com/s/a/470e93c06a9fffa6851375f54047917a9d774ed6027d9f044cd1bc8d4cd5630b.ttf
Run Code Online (Sandbox Code Playgroud)

Ami*_*r_P 5

这个错误可能有很多原因,但我认为其中之一是这种情况:

  1. 如果它只发生在 Android 上,那么您可能没有将其添加<uses-permission android:name="android.permission.INTERNET" />到清单文件中。
  2. 您所在的国家/地区禁止此服务