setSystemUIChangeCallback static method
- SystemUiChangeCallback? callback
Sets the callback method for responding to changes in the system UI.
This is relevant when using SystemUiMode.leanBack and SystemUiMode.immersive and SystemUiMode.immersiveSticky on Android platforms, where the SystemUiOverlays can appear and disappear based on user interaction.
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.
When using SystemUiMode.edgeToEdge, system overlays are always visible and do not change. When manually configuring SystemUiOverlays with SystemUiMode.manual, this callback will only be triggered when all overlays have been disabled. This results in the same behavior as SystemUiMode.leanBack.
Implementation
static Future<void> setSystemUIChangeCallback(SystemUiChangeCallback? callback) async {
ServicesBinding.instance.setSystemUiChangeCallback(callback);
// Skip setting up the listener if there is no callback.
if (callback != null) {
await SystemChannels.platform.invokeMethod<void>(
'SystemChrome.setSystemUIChangeListener',
);
}
}