欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 新闻 > 会展 > flutter 状态栏不显示 问题解决办法

flutter 状态栏不显示 问题解决办法

2025/5/10 13:23:47 来源:https://blog.csdn.net/hj960511/article/details/145653911  浏览:    关键词:flutter 状态栏不显示 问题解决办法

本篇文章主要讲解flutter 状态栏不显示 问题解决办法,通过本篇文章你可以快速解决遇到的这个问题。
日期:2025年2月15日
作者:任聪聪

现象说明:

现象1:不显示顶部的状态栏

在这里插入图片描述

现象2:不显示底部的 按钮

在这里插入图片描述

其他说明:

1、尝试通过AppBar解决无效。
2、设置全局样式参数无效。

  // 设置系统UI模式为正常模式,显示状态栏和导航栏SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);// 设置状态栏样式SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(statusBarColor: Colors.transparent, // 设置状态栏颜色为透明statusBarIconBrightness: Brightness.dark, // 设置状态栏图标为深色));

备注:总之很多方法都无效的情况。

问题原因:

这是由于位于:flutter\android\app\src\main\res\values-night\styles.xml文件下开启了全屏配置导致。

解决办法:

<?xml version="1.0" encoding="utf-8"?>
<resources><!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on --><style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar"><!-- Show a splash screen on the activity. Automatically removed whenthe Flutter engine draws its first frame --><item name="android:windowBackground">@drawable/launch_background</item><item name="android:forceDarkAllowed">false</item><item name="android:windowFullscreen">false</item><item name="android:windowDrawsSystemBarBackgrounds">true</item><item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item></style><!-- Theme applied to the Android Window as soon as the process has started.This theme determines the color of the Android Window while yourFlutter UI initializes, as well as behind your Flutter UI while itsrunning.This Theme is only used starting with V2 of Flutter's Android embedding. --><style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar"><item name="android:windowBackground">?android:colorBackground</item></style>
</resources>

说明: <item name="android:windowFullscreen">false</item> 此类目改为false即可。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词