Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

flutter

dart

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?

like image 755
iDecode Avatar asked Dec 03 '22 17:12

iDecode


2 Answers

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);
    
like image 147
iDecode Avatar answered Apr 29 '23 01:04

iDecode


Use setEnabledSystemUIMode instead of setEnabledSystemUIOverlays. Example:

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

change it to:

  SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.bottom, SystemUiOverlay.top]);
like image 39
Pavel L Avatar answered Apr 29 '23 02:04

Pavel L