SystemChrome
It is a class provided by Flutter to control the system-level behavior of the application, such as setting full screen, status bar, etc.
- Set the status bar to be transparent
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark, // 状态栏图标亮色
),
);
setSystemUIOverlayStyle
Set a transparent background and black icons for the status bar via .
- Modify the status bar text color to white
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle.dark.copyWith(
statusBarIconBrightness: Brightness.light,
),
);
setSystemUIOverlayStyle
Change the text color of the status bar to white by .
- Hide bottom navigation bar
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.top]);
By setEnabledSystemUIOverlays
hiding the bottom navigation bar, only the status bar is displayed.
- Prohibition of horizontal screen
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
By setPreferredOrientations
disabling screen landscape, only portrait orientation is allowed.
- Set full screen mode
SystemChrome.setEnabledSystemUIOverlays([]);
setEnabledSystemUIOverlays
Set full screen mode by , which hides the status bar, settings panel and navigation bar.
- Set the status bar highlight mode
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle.light,
);
setSystemUIOverlayStyle
Set 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