Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter change status bar brightness to dark

Tags:

flutter

dart

I tried several ways to make status bar icons dark, but after home press and returning to app status bar icons are white! it seems that its flutter bug.

but in iOS it works fine.

i tried these ways :

android app style:

<item name="android:windowLightStatusBar">false</item>

AppBar brightness:

brightness: Brightness.dark

Flutter API:

SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark.copyWith(
        statusBarIconBrightness: Brightness.dark
    ));

flutter_statusbarcolor package :

import 'package:flutter_statusbarcolor/flutter_statusbarcolor.dart';

FlutterStatusbarcolor.setStatusBarWhiteForeground(false);
like image 419
Hossein Avatar asked Mar 17 '19 17:03

Hossein


2 Answers

Add following into your widget tree:

AnnotatedRegion<SystemUiOverlayStyle>(
    value: SystemUiOverlayStyle.dark,
    child: ...
)
like image 82
Ainius Avatar answered Sep 25 '22 21:09

Ainius


As of Flutter 2.4.*, AppBar brightness is deprecated. To achieve status bar brightness, add a systemOverlayStyle to your AppBar as I have highlighted below.

appBar: AppBar(
  systemOverlayStyle: SystemUiOverlayStyle(
    statusBarBrightness: Brightness.dark
  ),
)

If you wish to apply dark status bar icons on the entire app, add an appBarTheme to your MaterialApp theme as shown in the following code. Your MaterialApp widget is on the main.dart file;

MaterialApp(
  ...
  theme: ThemeData(
    appBarTheme: AppBarTheme(
      systemOverlayStyle: SystemUiOverlayStyle(
        statusBarBrightness: Brightness.dark
      ),
    ),
  )
)
like image 42
Kenneth Murerwa Avatar answered Sep 26 '22 21:09

Kenneth Murerwa