Flutter:不使用AppBar时如何在Android和iOS上更改状态栏文本颜色

我是Flutter的新手,我在Google上搜索了此问题,但没有找到适合我的答案。

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

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(
     ...
}
评论
  • pculpa
    pculpa 回复

    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
    ));
    

    希望这可以帮助!干杯