I want to make the StatusBar transparent for Android in Flutter but for some reason I am getting black StatusBar on some of the screens. The minimum SDK is 20, targeting SDK 30.
I have tired all the suggestions from here but nothing works: How to hide Android StatusBar in Flutter
Also, I have tried the Flutter package for changing the StatusBar Color:
import 'package:flutter_statusbarcolor/flutter_statusbarcolor.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
FlutterStatusbarcolor.setStatusBarColor(Colors.transparent);
...
}
}
And I have tried placing this code on every page:
@override
initState() {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
));
super.initState();
}
With the two example codes above I only manage to make the StatusBar color transparent for the splash screen where I also have a background image. Example here:
Once the application loads the StatusBar becomes black:
Even more strange is when I switch trough the application screens, then the text in the StatusBar becomes black as well and remains this way until the application is restarted:
I suppose the black Status Bar can be due to the theme settings or another setting in my app influencing the StatusBar but noting I have tried so far works.
Ideally, I want to make that StatusBar transparent and have the text changing between black and white depending on the background color. It is ok to manually set the transparency and text color as long as it works.
Any suggestions?