4

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(
     ...
}
Felicia
  • 119
  • 6
  • please check this answer : https://stackoverflow.com/a/61025717/7666442 – AskNilesh May 17 '20 at 12:49
  • Hi @NileshRathod, thank you for your suggestion. I tried your answer right before post the question but it is not working on my case, an error keep showing `Utils` is not defined :( Do you know why? – Felicia May 17 '20 at 13:01
  • I have defined `Brightness.dark` and `Brightness.light` in and `Utils` class as a constant, that's why I have used like `Utils.androidWhiteIcon` – AskNilesh May 17 '20 at 13:11
  • lol well I see, btw I found the answer below works like charm! Thank youuuuuu anyway! – Felicia May 17 '20 at 13:33
  • 1
    BTW @NileshRathod could you please remove the [duplicate] tag of my question? Since this is not exactly the same to the question asked by the link you provided. @@ That one is asking about changing status bar color, but not status bar text color. – Felicia May 17 '20 at 13:36

1 Answers1

5

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

vanngoh
  • 626
  • 5
  • 15