Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: 第一次打开打开Flutter页面状态栏文字是黑色的,第二次之后打开Flutter页面时,状态栏文字变成白色的问题。 #1976

Closed
xiejiajin opened this issue Mar 1, 2024 · 3 comments

Comments

@xiejiajin
Copy link

请描述遇到的问题,以及您所期望的正确的结果

之前3.0版本也有这样的问题。在onPostResume 回调设置setStatusBarLightMode就可以了。现在flutter_boost升级到 5.0.1版本,这个设置也不起作用了,请问还有什么方法可以保持状态栏文字一直是黑色的吗?

请说明如何操作会遇到上述问题

图1
图2

在下面填入关键复现代码

复现的平台

Android

Flutter SDK版本

Flutter 3.16.5

FlutterBoost版本

flutter_boost 5.0.1

是否延迟初始化FlutterBoost

No

解决方案

@joechan-cq
Copy link
Collaborator

有一个临时的解决方法,在打开的flutter页面的widget的initState里

  void initState() {
    super.initState();
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);
    scheduleMicrotask(() {
      SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
    });
  }

@xiejiajin
Copy link
Author

有一个临时的解决方法,在打开的flutter页面的widget的initState里

  void initState() {
    super.initState();
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);
    scheduleMicrotask(() {
      SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
    });
  }

这个是有效果,不过也回出现状态栏闪动的情况。
我现在的解决方法是,在继承FlutterBoostActivity类中,重写onUpdateSystemUiOverlays,注释掉super.onUpdateSystemUiOverlays()
` @OverRide
protected void onUpdateSystemUiOverlays() {
// super.onUpdateSystemUiOverlays();//状态栏颜色会变
LogUtil.e(TAG, "onUpdateSystemUiOverlays");

}`

@joechan-cq
Copy link
Collaborator

PRmerge至了5.x的版本分支上,4.x分支目前没有。需要的自行Merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants