简体   繁体   English

如何在flutter app中更改状态栏颜色,仅在一页中

[英]How to change the status bar color in flutter app, only in one page

I want to change the status bar color of the app in specific page.我想更改特定页面中应用程序的状态栏颜色。

used code:使用代码:

      SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
        statusBarColor:Colors.white, 
        systemNavigationBarColor: Colors.grey[200],
      ))

above will change the color, but how to do that just for the specific page, I am using navigator.上面会改变颜色,但是如何只针对特定页面做那件事,我正在使用导航器。 for navigation.用于导航。

Use your code just above the build method of every page you create.在您创建的每个页面的构建方法上方使用您的代码。

So for one scaffold, call this above the scaffold's build method to change the status bar color to grey所以对于一个脚手架,在脚手架的 build 方法上方调用它来将状态栏颜色更改为灰色

SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
  statusBarColor: Colors.white, 
  systemNavigationBarColor: Colors.grey[200],
))

To change it back for another screen, simply recall the code with a different color above that screen's scaffold's build method:要将其改回另一个屏幕,只需回忆一下该屏幕脚手架的构建方法上方具有不同颜色的代码:

SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
      statusBarColor: Colors.black, 
      systemNavigationBarColor: Colors.grey[200],
    ))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM