[英]how can I change the status bar icon color to white in flutter
The status bar color should be black and its icons/texts colors should be white.状态栏颜色应为黑色,其图标/文本 colors 应为白色。 But it is not working.但它不起作用。 Here is my code.这是我的代码。 Dear experts, please help me to solve it.各位高手,请帮我解决一下。 Thank you.谢谢你。
First Page image here.第一页图片在这里。 [ 2 : https://i.stack.imgur.com/sXU97.png][2] [ 2 : https://i.stack.imgur.com/sXU97.png][2]
We need to use systemNavigationBarIconBrightness: Brightness.dark,
to get white on android and rebuild the app.我们需要使用systemNavigationBarIconBrightness: Brightness.dark,
在 android 上变白并重建应用程序。
When set to [Brightness.light], the system navigation bar icons are light.当设置为[Brightness.light]时,系统导航栏图标为浅色。
When set to [Brightness.dark], the system navigation bar icons are dark.设置为【亮度.暗】时,系统导航栏图标为深色。
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(
statusBarColor: Colors.black, // status bar color
systemNavigationBarIconBrightness: Brightness.dark, // Icon Color
),
);
I know I am late but for those who face the same issue我知道我迟到了,但对于那些面临同样问题的人
Add the following code to main.dart
in the MaterialApp()
theme property在MaterialApp()
主题属性中的main.dart
添加如下代码
MaterialApp(
theme: ThemeData(
appBarTheme: AppBarTheme(
systemOverlayStyle: const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarBrightness: Brightness.dark, // For iOS: (dark icons)
statusBarIconBrightness: Brightness.dark, // For Android(M and greater): (dark icons)
))),
);
Noting that Brightness.dark
provide dark icons and that's suitable for white background in black background case of course Brightness.light
注意到Brightness.dark
提供深色图标,这当然适用于黑色背景情况下的白色背景Brightness.light
That will work globally in your app这将在您的应用程序中全局运行
If you want it for a specific page, there's a property in AppBar()
called systemOverlayStyle:
copy the same code above to it如果你想要它用于特定页面, AppBar()
中有一个名为systemOverlayStyle:
将上面的相同代码复制到它
AppBar(
systemOverlayStyle: const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarBrightness: Brightness.dark, // For iOS: (dark icons)
statusBarIconBrightness: Brightness.dark, // For Android(M and greater): (dark icons)
),
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.