Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Android status bar light in Flutter

As the title suggests, this is about Flutter.

Is there any way to switch Android status bar to light mode so that the icons in status bar show up dark? See picture for example.

I tried following possible solutions but none of them worked -

// main.dart
appBar: new AppBar(
      brightness: Brightness.light,
      backgroundColor: Colors.white,
    ),

// MainActivity.kt
// Following 2 lines do change the color of status and nav bars
window.statusBarColor = 0x00000000
window.navigationBarColor = 0x00000000

// This seems to have no effect. Icons are still white.
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR

enter image description here


UPDATE

The support for this is in works - https://github.com/flutter/flutter/issues/17231

like image 593
hvkale Avatar asked Mar 08 '18 17:03

hvkale


People also ask

How do I make the status bar color white in Flutter?

Step 1: Locate the MaterialApp widget. Step 2: Inside the MaterialApp, add the theme parameter with ThemeData class assigned. Step 3: Inside the ThemeData add the appBarTheme parameter and then assign the AppBarTheme class. Step 4: Inside the AppBarTheme , specify the systemOverlayStyle parameter and set the color.

How do I make my status bar white on Android?

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 you change the color of your Flutter?

Step 1: Locate the file where you have placed the Text widget. Step 2: Inside the Text widget, add the Style parameter and assign the TextStyle widget. Step 3: Inside the TextStyle widget, add the color parameter and set the color of your choice. For example, color: Colors.


2 Answers

Just additional notes:

To change the status bar icon to dark put the following code

StatusBarIconBrightness: Brightness.light

and add brightness in appbar.

appBar: AppBar(  
brightness: Brightness.light, )

if you would like to use white bg on status bar, then change to .light so that icon can be dark, and .dark for darker status bar with white icon

like image 61
Shahril aidi Avatar answered Oct 08 '22 23:10

Shahril aidi


The Flutter team have now added support for light/dark status bar control. To add, import this:

import 'package:flutter/services.dart';

Then add this in your App's build function:

SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark.copyWith(
  statusBarIconBrightness: Brightness.dark
));
like image 18
Colin White Avatar answered Oct 08 '22 23:10

Colin White