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"文件,请确保对它做同样的操作。

相关推荐
恋猫de小郭1 小时前
Flutter 的另外一种形态?社区 DartNative 要来了。
android·前端·flutter
阿里云云原生16 小时前
还原一次用户等待:深度解析 Flutter RUM SDK 如何打通 Dart 到 Native 的观测链路
flutter
_阿南_18 小时前
flutter 展示的字体突然奔放了
android·flutter·ios
GitLqr21 小时前
玩转 Dart typedef:不仅是函数别名那么简单
flutter·面试·dart
FungLeo1 天前
Flutter 两个反直觉布局坑:ListTile 水波纹 / VerticalDivider 踩坑实录
android·flutter
年小个大1 天前
受 go-zero 启发,我给 Flutter 写了一套 CLI 脚手架
android·flutter·架构
FungLeo2 天前
Flutter 骨架屏 Shimmer 实现:不用 transform 的扫光法实战
前端·javascript·flutter
GitLqr2 天前
Flutter 居然能直接跑在 Apple Watch 上了?玩转 flutter-watchos
flutter·全栈·apple watch
你听得到112 天前
排查 App 问题:别只盯着报错,把前后发生的事情串起来
android·前端·flutter
天空之城--2 天前
近一周Android Flutter行业动态与实用参考
android·flutter