setEnabledSystemUIMode static method
- SystemUiMode mode, {
- List<
SystemUiOverlay> ? overlays,
Specifies the SystemUiMode to have visible when the application is running.
The overlays
argument is a list of SystemUiOverlay enum values
denoting the overlays to show when configured with SystemUiMode.manual.
If a particular mode is unsupported on the platform, enabling or disabling that mode will be ignored.
The settings here can be overridden by the platform when System UI becomes necessary for functionality.
For example, on Android, when the keyboard becomes visible, it will enable the navigation bar and status bar system UI overlays. When the keyboard is closed, Android will not restore the previous UI visibility settings, and the UI visibility cannot be changed until 1 second after the keyboard is closed to prevent malware locking users from navigation buttons.
To regain "fullscreen" after text entry, the UI overlays can be set again after a delay of at least 1 second through restoreSystemUIOverlays or calling this again. Otherwise, the original UI overlay settings will be automatically restored only when the application loses and regains focus.
Alternatively, a SystemUiChangeCallback can be provided to respond to
changes in the System UI. This will be called, for example, when in
SystemUiMode.leanBack and the user taps the screen to bring up the
system overlays. The callback provides a boolean to represent if the
application is currently in a fullscreen mode or not, so that the
application can respond to these changes. When systemOverlaysAreVisible
is true, the application is not fullscreen. See
SystemChrome.setSystemUIChangeCallback to respond to these changes in a
fullscreen application.
Implementation
static Future<void> setEnabledSystemUIMode(SystemUiMode mode, { List<SystemUiOverlay>? overlays }) async {
if (mode != SystemUiMode.manual) {
await SystemChannels.platform.invokeMethod<void>(
'SystemChrome.setEnabledSystemUIMode',
mode.toString(),
);
} else {
assert(mode == SystemUiMode.manual && overlays != null);
await SystemChannels.platform.invokeMethod<void>(
'SystemChrome.setEnabledSystemUIOverlays',
_stringify(overlays!),
);
}
}