Flutter 挖孔屏的状态栏占用问题怎么解决,横屏后去掉了状态栏,还是会有一块黑色的竖条

使用下方代码后依旧有一条黑色的区域

Dart 复制代码
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    ///关闭状态栏,与底部虚拟操作按钮
    SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);//隐藏状态栏,底部按钮栏
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.landscapeLeft,
      DeviceOrientation.landscapeRight,
    ]);
  }
  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    ///显示状态栏,与底部虚拟操作按钮
    SystemChrome.setEnabledSystemUIOverlays(
        [SystemUiOverlay.top, SystemUiOverlay.bottom]);
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
      DeviceOrientation.portraitDown,
    ]);
  }

在这种情况下是因为相机,你可以通过以下方式解决这个问题:

android/app/src/main/res/values/styles.xml

并添加以下行:

Dart 复制代码
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>

这就是我的"styles.xml"现在的样子:

Dart 复制代码
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item> <!-- This is the added line -->
</style>
</resources>

如果你在"values-nigh"文件夹中有另一个"styles.xml"文件,请确保对它做同样的操作。

相关推荐
nc_kai2 小时前
Flutter 之 每日翻译 PreferredSizeWidget
java·前端·flutter
littlegnal3 小时前
Flutter Add-to-app profiling
flutter
0wioiw010 小时前
Flutter基础(FFI)
flutter
Georgewu9 天前
【HarmonyOS 5】鸿蒙跨平台开发方案详解(一)
flutter·harmonyos
爱吃鱼的锅包肉10 天前
Flutter开发中记录一个非常好用的图片缓存清理的插件
flutter
张风捷特烈10 天前
每日一题 Flutter#13 | build 回调的 BuildContext 是什么
android·flutter·面试
恋猫de小郭10 天前
Flutter 又双叒叕可以在 iOS 26 的真机上 hotload 运行了,来看看又是什么黑科技
android·前端·flutter
QC七哥11 天前
跨平台开发flutter初体验
android·flutter·安卓·桌面开发
小喷友11 天前
Flutter 从入门到精通(水)
前端·flutter·app