Home > Mobile >  Full Screen Flutter
Full Screen Flutter

Time:09-27

How to enable and disable a full-screen mode in the check box. I think this is the use if and else statement. I will share my code.

 onChanged: (val) {
                setState(() {
                  thu = val!;
                  SystemChrome.setEnabledSystemUIMode(
                    SystemUiMode.manual,
                    overlays: [SystemUiOverlay.bottom],
                  );
                });
              }),

CodePudding user response:

Assuming that valis a boolean, e.g. from a switch, you can use the following if-else statement to distinguish between the two cases.

 onChanged: (val) {
   setState(() {
     if (val) { // Fullscreen mode
       SystemChrome.setEnabledSystemUIMode(
         overlays: [],
       );
     } else { // Disable fullscreen mode
       SystemChrome.setEnabledSystemUIMode(
         overlays: SystemUiOverlay.values,
       );
     }
   });
 }),

You can refer to this question for more information on the SystemChrome.setEnabledSystemUIMode method.

CodePudding user response:

try this // to hide only bottom bar:

SystemChrome.setEnabledSystemUIOverlays ([SystemUiOverlay.top]);

// to hide only status bar:

SystemChrome.setEnabledSystemUIOverlays ([SystemUiOverlay.bottom]);

// to hide both:

SystemChrome.setEnabledSystemUIOverlays ([]);
  • Related