如何在导航到屏幕时控制 Flutter 状态栏颜色

问题描述 投票:0回答:1

在我的Flutter应用程序中,有3个页面,SplashScreen、HomePage和Notification Page,这三个页面我都使用了不同的状态栏颜色,我的splashscreen的状态栏颜色是白色,Homepage和Notification的状态栏颜色是红色。当我正常打开我的应用程序时,它会显示带有白色状态栏的启动屏幕,然后移动到带有红色状态栏的主页,当我单击通知托盘时,有时它会显示通知页面状态栏的正确颜色但有时它会显示通知页面的白色状态栏颜色,可能是什么原因导致此类问题?

android flutter push-notification
1个回答
0
投票

根据您的偏好以及导航返回时在每个页面初始化上触发此操作(使用 willpopscope/dispose/ onPressBack 等)。

 SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
        statusBarBrightness: isDarkTheme ? Brightness.dark : Brightness.light,
        statusBarIconBrightness:
            isDarkTheme ? Brightness.light : Brightness.dark,
      ));
© www.soinside.com 2019 - 2024. All rights reserved.