问题
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);
回答1:
Add following into your widget tree:
AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle.dark,
child: ...
)
回答2:
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
),
来源:https://stackoverflow.com/questions/55209774/flutter-change-status-bar-brightness-to-dark