简体   繁体   English

有没有办法改变 flutter 状态栏图标?

[英]Is there anyway to change flutter status bar icon?

I want to change the status bar icon for my apps.我想更改我的应用程序的状态栏图标。 I know we can change the status bar color and the icon can be either black or white if we use Brightness.light or Brightness.dark respectively.我知道我们可以更改状态栏颜色,如果我们分别使用Brightness.lightBrightness.dark ,图标可以是黑色或白色。 But is there any ways to change the icon, for example i want the icon to be blue in color.但是有什么方法可以更改图标,例如我希望图标为蓝色。 Any help is really appreciated, thanks.非常感谢任何帮助,谢谢。

This is what you can do with the status bar by using SystemUiOverlayStyle :这是您可以使用SystemUiOverlayStyle对状态栏执行的操作:


void main() {
  SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
    systemNavigationBarColor: Colors.blue,
    // navigation bar color
    statusBarColor: Colors.pink,
    // status bar color
    statusBarBrightness: Brightness.dark,
    //status bar brigtness
    statusBarIconBrightness: Brightness.dark,
    //status barIcon Brightness
    systemNavigationBarDividerColor: Colors.greenAccent,
    //Navigation bar divider color
    systemNavigationBarIconBrightness: Brightness.light, //navigation bar icon
  ));
  runApp(MyApp());
}

To customize system UI for Android for example, you'll have to modify the source code of Android, which can be found in this documentation .例如,要为 Android 自定义系统 UI,您必须修改 Android 的源代码,可以在本文档中找到。 It's recommended to build the UI as per the default config though, since it will be harder for your app to accommodate future updates to the SDK.建议按照默认配置构建 UI,因为您的应用程序将更难适应 SDK 的未来更新。

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

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