Reputation: 28986
I was using the following code to show only status bar.
SystemChrome.setEnabledSystemUIOverlays([
SystemUiOverlay.top
])
but it started giving me a warning:
setEnabledSystemUIOverlays is deprecated and shouldn't be used. Migrate to setEnabledSystemUIMode.
So, how do I fix it?
Upvotes: 20
Views: 21462
Reputation: 28986
Use setEnabledSystemUIMode
and provide SystemUiMode.manual
as shown below:
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [
SystemUiOverlay.top
]);
You can also use SystemUiMode
Hide both overlays:
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
Show both overlays:
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
But where to use this code?
Consider placing it in main()
for a global application effect, within initState
for widget-specific behavior, or inside a callback for event-driven actions.
Upvotes: 48
Reputation: 4186
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
It doesn't show up again after touching the screen
Upvotes: 2
Reputation: 111
Use setEnabledSystemUIMode instead of setEnabledSystemUIOverlays. Example:
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom, SystemUiOverlay.top]);
change it to:
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.bottom, SystemUiOverlay.top]);
Upvotes: 10