iDecode
iDecode

Reputation: 28986

setEnabledSystemUIOverlays is deprecated and shouldn't be used. Migrate to setEnabledSystemUIMode

I was using the following code to show only status bar.

SystemChrome.setEnabledSystemUIOverlays([
  SystemUiOverlay.top
])

but it started giving me a warning:

setEnabledSystemUIOverlays is deprecated and shouldn't be used. Migrate to setEnabledSystemUIMode.

So, how do I fix it?

Upvotes: 20

Views: 21462

Answers (3)

iDecode
iDecode

Reputation: 28986

Use setEnabledSystemUIMode and provide SystemUiMode.manual as shown below:

SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [
  SystemUiOverlay.top
]);

You can also use SystemUiMode

  1. Hide both overlays:

    SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
    
  2. Show both overlays:

    SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
    

But where to use this code?

Consider placing it in main() for a global application effect, within initState for widget-specific behavior, or inside a callback for event-driven actions.

Upvotes: 48

Dani
Dani

Reputation: 4186

SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);

It doesn't show up again after touching the screen

Upvotes: 2

Pavel L
Pavel L

Reputation: 111

Use setEnabledSystemUIMode instead of setEnabledSystemUIOverlays. Example:

  SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom, SystemUiOverlay.top]);

change it to:

  SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.bottom, SystemUiOverlay.top]);

Upvotes: 10

Related Questions