SystemChrome in Flutter is used to control the system-level behavior of the application

SystemChromeIt is a class provided by Flutter to control the system-level behavior of the application, such as setting full screen, status bar, etc.

  1. Set the status bar to be transparent
SystemChrome.setSystemUIOverlayStyle(
  SystemUiOverlayStyle(
    statusBarColor: Colors.transparent,
    statusBarIconBrightness: Brightness.dark, // 状态栏图标亮色
  ),
);

setSystemUIOverlayStyleSet a transparent background and black icons for the status bar via .

  1. Modify the status bar text color to white
SystemChrome.setSystemUIOverlayStyle(
  SystemUiOverlayStyle.dark.copyWith(
    statusBarIconBrightness: Brightness.light,
  ),
);

setSystemUIOverlayStyleChange the text color of the status bar to white by .

  1. Hide bottom navigation bar
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.top]);

By setEnabledSystemUIOverlayshiding the bottom navigation bar, only the status bar is displayed.

  1. Prohibition of horizontal screen
SystemChrome.setPreferredOrientations([
  DeviceOrientation.portraitUp,
  DeviceOrientation.portraitDown,
]);

By setPreferredOrientationsdisabling screen landscape, only portrait orientation is allowed.

  1. Set full screen mode
SystemChrome.setEnabledSystemUIOverlays([]);

setEnabledSystemUIOverlaysSet full screen mode by , which hides the status bar, settings panel and navigation bar.

  1. Set the status bar highlight mode
SystemChrome.setSystemUIOverlayStyle(
  SystemUiOverlayStyle.light,
);

setSystemUIOverlayStyleSet the icon and text of the status bar to a light color by .


If you are interested, you can pay attention to my comprehensive official account: biglead

Guess you like

Origin blog.csdn.net/zl18603543572/article/details/130517305