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?


Solution 1: iDecode

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);
    


Solution 2: Pavel L

Use setEnabledSystemUIMode instead of setEnabledSystemUIOverlays. Example:

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

change it to:

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


Solution 3: Dani

SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);

It doesn't show up again after touching the screen