使用 android 12 api31 在 Flutter 中全屏

And*_*rei 6 android dart flutter android-12 android-api-31

大家好,我的全屏有问题,我尝试了各种设置,但无法在 android 12 api31 上获得全屏。

目前我已经这样设置了。

我像这样运行应用程序

SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []).then(
      (_) => runApp(MyApp()),
);
Run Code Online (Sandbox Code Playgroud)

在 styles.xml 中

<style name="NormalTheme" parent="@android:style/Theme.Translucent.NoTitleBar">
    // Important to draw behind cutouts
    <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>
Run Code Online (Sandbox Code Playgroud)

在AndroidManifest.xml中

 android:windowSoftInputMode="adjustResize"
Run Code Online (Sandbox Code Playgroud)

我也尝试过其他的事情,但目前我得到的最好的结果是这个

return Scaffold(
    body: Container(
      color: Colors.deepPurple,
      child: const Center(
        child: Text(
          "Container full",
          style: TextStyle(fontSize: 40),
        ),
      ),
    ),
    );
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我想覆盖整个屏幕,但我什至无法覆盖缺口

最终结果应该是这样的。我希望能够操纵我的应用程序的整个屏幕空间。我不想要系统栏。

在此输入图像描述

小智 0

您需要操作 SystemChrome 设置。像这个:

SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
Run Code Online (Sandbox Code Playgroud)

我认为阅读它的文档也会很有用。 文档

如果它在 iOS 上不适合您,您始终可以使用manual值作为启用的系统 UI 模式自行操作叠加层。但您实际上忘记了要启用哪些叠加层。你也可以尝试这个:

SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
  overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom]);
Run Code Online (Sandbox Code Playgroud)