Flutter:不使用AppBar时如何在Android和iOS上更改状态栏文本颜色 [英] Flutter: How to change the status bar text color on Android and iOS when not using AppBar
本文介绍了Flutter:不使用AppBar时如何在Android和iOS上更改状态栏文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Flutter的新手,我在Google上搜索了这个问题,但没有找到适合我的答案.
I'm new to Flutter, I googled about this question but found no answer works for me.
我的代码如下所示,状态栏颜色很好用,现在是白色.但是Android上的状态栏文本颜色也是白色,似乎 Brightness.dark
根本不起作用...
My code is shown as below, the status bar color works well, it is white now. But the status bar text color on Android is also white, seems like the Brightness.dark
not working at all...
您的回答将不胜感激,谢谢!< 3
Your answer will be appreciated, thank you! <3
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark.copyWith(
statusBarColor: Colors.white, // Color for Android
statusBarBrightness: Brightness.dark // Dark == white status bar -- for IOS.
));
return Scaffold(
body: Container(
...
}
推荐答案
According to the SystemUiOverLayStyle API docs, the text color of status bar on Android cannot be changed by statusBarBrightness
which is only honored in iOS.
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.white, // Only honored in Android M and above
statusBarIconBrightness: Brightness.dark // Only honored in Android M and above
statusBarBrightness: Brightness.light, // Only honored in iOS
));
希望这会有所帮助!干杯
Hope this helps! Cheers
这篇关于Flutter:不使用AppBar时如何在Android和iOS上更改状态栏文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文