Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the status bar text color on Ios

Tags:

flutter

I am new to all this flutter thing. I searched everywhere to find a solution for this little problem. Is there a way to change the status bar color? Also when i use the a color like colors.blue i can see that the quality of the text in the status bar isn't good.

Thanks

enter image description here

appBar: AppBar(
    elevation : 0.0,
    leading: IconButton(
      icon: Icon(Icons.menu),
      tooltip: 'Navigation menu',
      onPressed: null,
    ),
    actions: <Widget>[
      IconButton(
        icon: Icon(Icons.search),
        tooltip: 'Search',
        onPressed: null,
      ),
    ],
  ),
like image 460
Antoine Avatar asked Aug 06 '18 13:08

Antoine


People also ask

How do I change the color of my status bar on my Iphone?

Go to the Storyboard. Select the View and in the Attributes Inspector change the Background Color to Light Gray. Build and Run the Project. The default style of the status bar is dark content.

How do I change the color of my status bar text?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar.

How do I change the color of my status bar in Swift?

Open your info. plist and set UIViewControllerBasedStatusBarAppearance to false . In the first function in AppDelegate. swift , which contains didFinishLaunchingWithOptions , set the color you want.


4 Answers

@Antoine Basically you can set your theme Brightness, or you can manually override the appbar brightness using the following :

appBar: new AppBar(
  title: new Text(widget.title),
  brightness: Brightness.light, // or use Brightness.dark
),

Do note that this will only switch between white and black status text color.

.dark will make the status bar text WHITE, while .light will make the status bar text BLACK.

Maybe for a more custom color, like the comment said you can view SystemChrome class.

like image 137
Allan Ho Avatar answered Oct 22 '22 01:10

Allan Ho


When I don't use AppBar, the colour can be changed using AnnotatedRegion.

import 'package:flutter/services.dart';

...    

Widget build(BuildContext context) {
   return Scaffold(
      body: AnnotatedRegion<SystemUiOverlayStyle>(
         value: SystemUiOverlayStyle.light,                
         child: ...,
      ),
   );
}
like image 25
Ares Avatar answered Oct 22 '22 00:10

Ares


For IOS and Android:

SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark.copyWith(
   statusBarColor: Colors.white, // Color for Android
   statusBarBrightness: Brightness.dark // Dark == white status bar -- for IOS.
));
like image 51
Lucas Paz Avatar answered Oct 22 '22 00:10

Lucas Paz


AnnotatedRegion helps you change status bar text color on iOS.

import 'package:flutter/services.dart';
...    

Widget build(BuildContext context) {
   return AnnotatedRegion<SystemUiOverlayStyle>(
         value: SystemUiOverlayStyle.dark,                
         child: ...,
   );
}

But if you have AppBar in Scaffold then only AnnotatedRegion won't work. Here is solution.

  Widget build(BuildContext context) {
    return AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle.dark, // play with this
      child: Scaffold(
        appBar: AppBar(
          brightness: Brightness.light, // play with this
        ),
        body: Container(),
     );
  }
like image 7
Sandeep Maurya Avatar answered Oct 22 '22 01:10

Sandeep Maurya