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
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,
),
],
),
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.
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.
Open your info. plist and set UIViewControllerBasedStatusBarAppearance to false . In the first function in AppDelegate. swift , which contains didFinishLaunchingWithOptions , set the color you want.
@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.
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: ...,
),
);
}
For IOS and Android:
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark.copyWith(
statusBarColor: Colors.white, // Color for Android
statusBarBrightness: Brightness.dark // Dark == white status bar -- for IOS.
));
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(),
);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With