为什么中文文本有时不出现在Flutter应用程序中?

oyjwcjzk  于 2023-10-22  发布在  Flutter
关注(0)|答案(1)|浏览(164)

我有一个使用Flutter的应用程序。一些用户说,他们有时打开应用程序时看不到中文文本。
第一个图像是正常状态。第二张图片是用户的屏幕截图,你可以看到所有的中文文本都没有出现。
在我将Flutter从3.7更新到3.13之前没有任何问题,并且只有Android用户报告了这个问题。如果用户卸载应用程序,然后重新启动手机,然后重新安装应用程序,这将是确定的。
我不能自己复制这个。有人有什么想法吗?非常感谢
10.19更新:
以下文本是中文文本未出现时的错误:

2023-10-19 11:57:55.904 25798-25961 SuggestManager          com.miui.securitycenter.remote       E  openApp name = com.xxx.xxx
2023-10-19 11:57:55.910  9459-9459  ForceDarkHelper         com.xxx.xxx                 D  updateByCheckExcludeList: pkg: com.xxx.xxx activity: com.xxx.xxx.MainActivity@b27f842
2023-10-19 11:57:55.911  9459-9490  ViewContentFactory      com.xxx.xxx                 D  initViewContentFetcherClass
2023-10-19 11:57:55.911  9459-9490  ContentCatcher          com.xxx.xxx                 I  ViewContentFetcher : ViewContentFetcher
2023-10-19 11:57:55.911  9459-9490  ViewContentFactory      com.xxx.xxx                 D  createInterceptor took 0ms
2023-10-19 11:57:55.911  9459-9459  ForceDarkHelper         com.xxx.xxx                 D  updateByCheckExcludeList: pkg: com.xxx.xxx activity: com.xxx.xxx.MainActivity@b27f842
2023-10-19 11:57:55.912  9459-9459  chatty                  com.xxx.xxx                 I  uid=10295(com.xxx.xxx) identical 1 line
2023-10-19 11:57:55.912  9459-9459  ForceDarkHelper         com.xxx.xxx                 D  updateByCheckExcludeList: pkg: com.xxx.xxx activity: com.xxx.xxx.MainActivity@b27f842
2023-10-19 11:57:55.932  9459-9459  ForceDarkHelper         com.xxx.xxx                 D  updateByCheckExcludeList: pkg: com.xxx.xxx activity: com.xxx.xxx.MainActivity@b27f842
2023-10-19 11:57:55.932  9459-9459  ForceDarkHelper         com.xxx.xxx                 D  updateByCheckExcludeList: pkg: com.xxx.xxx activity: com.xxx.xxx.MainActivity@b27f842
2023-10-19 11:57:55.953  9459-9459  ForceDarkHelper         com.xxx.xxx                 D  updateByCheckExcludeList: pkg: com.xxx.xxx activity: com.xxx.xxx.MainActivity@b27f842
2023-10-19 11:57:55.958  9459-9459  EgretLoader             com.xxx.xxx                 D  EgretLoader(Context context)
2023-10-19 11:57:55.959  9459-9459  EgretLoader             com.xxx.xxx                 D  The context is not activity
2023-10-19 11:57:55.975  9459-9459  SurfaceView             com.xxx.xxx                 D  UPDATE null, mIsCastMode = false
2023-10-19 11:57:55.998  9459-9459  ForceDarkHelper         com.xxx.xxx                 D  updateByCheckExcludeList: pkg: com.xxx.xxx activity: com.xxx.xxx.MainActivity@b27f842
2023-10-19 11:57:56.001  9459-9459  EgretLoader             com.xxx.xxx                 D  EgretLoader(Context context)
2023-10-19 11:57:56.001  9459-9459  EgretLoader             com.xxx.xxx                 D  The context is not activity
2023-10-19 11:57:56.024  9459-9459  ForceDarkHelper         com.xxx.xxx                 D  updateByCheckExcludeList: pkg: com.xxx.xxx activity: com.xxx.xxx.MainActivity@b27f842
2023-10-19 11:57:56.028  9459-9459  EgretLoader             com.xxx.xxx                 D  EgretLoader(Context context)
2023-10-19 11:57:56.029  9459-9459  EgretLoader             com.xxx.xxx                 D  The context is not activity
kt06eoxx

kt06eoxx1#

我可能解决了这个问题,但我仍然不知道根本原因。
我把main函数从javascript改为sync,并把main函数中的javascript代码移到了其他地方。
使用前:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // ...
  await PackageInfo.fromPlatform()
  // ... there are a few async methods

  runApp(const RestartApp(child: MyApp()));
}

之后:

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  // Every async methods were removed

  runApp(const RestartApp(child: MyApp()));
}

在进行此更改后,我无法在Android测试驱动器(Android 10)上重现此问题。我不知道我的应用程序用户在电话上是否可以,如果有人向我报告,我会改变答案。

相关问题