项目背景:
在Android 中 嵌入 webview,实现 H5 游戏,想让Flutter实现 全屏显示(沉浸式),发现刘海屏 和 水滴屏幕 刘海部位是 黑色,填坑发现需要配置一下;
Flutter 全面屏显示
全屏显示:
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
恢复App状态栏:
// 方式 1
// SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
// overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom]);
// 方式 2
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
overlays: SystemUiOverlay.values);
如果需要适配全面屏: 需要在原生 res/values/style/style.xml 文件中添加:
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>