Home > Software design >  Unable to hide status bar - Flutter - This expression has a type of 'void' so its value ca
Unable to hide status bar - Flutter - This expression has a type of 'void' so its value ca

Time:04-18

Seeing the following error on setSystemUIOverlayStyle.

Do I have to add some package to pubspec.yaml?

error

errors: enter image description here

CodePudding user response:

You can set the StatusBar transparent by adding this in your main():

SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
        statusBarColor: Colors.transparent));

The problem is that you are putting it inside your runApp(). Your main() should look like this:

void main() {
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
        statusBarColor: Colors.transparent));
runApp(const MyApp());
}

CodePudding user response:

Try below code I think you write wrong code. for more refer image

CodePudding user response:

You can add line this to init state and import flutter services package that's it.. Cheers..

SystemChrome.setEnabledSystemUIMode(SystemUiMode.leanBack);
  • Related