【问题标题】:Full screen in Flutter with android 12 api31使用 android 12 api31 在 Flutter 中全屏显示
【发布时间】:2022-12-11 06:05:55
【问题描述】:

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

目前我是这样设置的。

我这样运行应用程序

SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []).then(
      (_) => runApp(MyApp()),
);

在 styles.xml 中

<style name="NormalTheme" parent="@android:style/Theme.Translucent.NoTitleBar">
    // Important to draw behind cutouts
    <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>

在 AndroidManifest.xml 中

 android:windowSoftInputMode="adjustResize"

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

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

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

最后的结果应该是这样的。 我希望能够为我的应用操纵整个屏幕空间。 我不要系统吧。

【问题讨论】:

  • 你到底想做什么?你能提供更多的说明吗?
  • 我想要一个完整的屏幕,目前我有一个黑色空间,正如你在照片中看到的那样
  • 你想覆盖整个屏幕吗?
  • 是的,我希望整个屏幕都能使用
  • 然后拿一个 Container 并用 MediaQuery.of(context).size.width 添加它的 width 属性。

标签: android flutter dart android-12 android-api-31


【解决方案1】:

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

SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);

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

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

SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
  overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom]);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-20
    • 2019-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-25
    • 2022-10-23
    相关资源
    最近更新 更多