10

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);
Hossein
  • 797
  • 1
  • 8
  • 24
  • refer this links - https://pub.dartlang.org/packages/flutter_statusbar_manager#-readme-tab- - https://pub.dartlang.org/packages/flutter_statusbarcolor#-readme-tab- –  Mar 20 '19 at 05:38
  • thanks, but has same problem. – Hossein Mar 20 '19 at 11:12

7 Answers7

17

Add following into your widget tree:

AnnotatedRegion<SystemUiOverlayStyle>(
    value: SystemUiOverlayStyle.dark,
    child: ...
)
Ainius
  • 336
  • 3
  • 11
6

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
      ),
    ),
  )
)
Kenneth Murerwa
  • 778
  • 12
  • 16
3
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
  statusBarColor: Colors.white
));

This is only working when there is no appbar. If there is an app bar, this will not work. So you will have to change the brightness of appbar first.

appBar: new AppBar(
        brightness: Brightness.light, // Add this line
      ),
Hasitha
  • 41
  • 1
  • 5
1

If you want to change the theme for the app as a whole, I would recommend this answer to a similar problem: https://stackoverflow.com/a/62607827/15605135

If you want to change a single AppBar, you could try to use the systemOverlayStyle property:

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        systemOverlayStyle: SystemUiOverlayStyle.dark,
      ),
    );
  }
tstrmn
  • 297
  • 1
  • 9
0

Wrap your widget with SafeArea and include brightness in your appBar and it will work.

  void main()
{
  SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(statusBarColor: Colors.deepPurple,
  statusBarBrightness: Brightness.dark,
  ));
  runApp(MyApp());
}
    return SafeArea(child: Scaffold(
      appBar: AppBar(
          toolbarHeight: 50,
          centerTitle: true,
          brightness: Brightness.dark,
          backgroundColor: Colors.deepPurple,
          child: Text("Your Text"),),
0

Use:-

systemOverlayStyle: SystemUiOverlayStyle.dark,

instead of:

brightness: Brightness.dark,

  • 1
    This is the same solution as in [this other answer](https://stackoverflow.com/a/56556590/2227743). *When answering older questions that already have answers, please make sure you provide either a novel solution or a significantly better explanation than existing answers.* – Eric Aya Sep 21 '21 at 11:52
0

Apply for all appBar use

return MaterialApp(
        theme: ThemeData(
            appBarTheme: Theme.of(context)
                .appBarTheme
                .copyWith(systemOverlayStyle: SystemUiOverlayStyle.dark)),
        debugShowCheckedModeBanner: false,
        home: widget());

I hope it works.

Ema
  • 71
  • 1
  • 2