Flutter: How to change the status bar text color on Android and iOS when not using AppBar

Viewed 1320

I'm new to Flutter, I googled about this question but found no answer works for me.

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...

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(
     ...
}
1 Answers

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

Related