当前位置: 首页 > article >正文

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 when
             the 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 your
         Flutter UI initializes, as well as behind your Flutter UI while its
         running.

         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即可。


http://www.kler.cn/a/548277.html

相关文章:

  • Rust编程语言入门教程(二)hello_world
  • 开源模型应用落地-Qwen1.5-MoE-A2.7B-Chat与vllm实现推理加速的正确姿势(一)
  • Zookeeper(45) 如何在Zookeeper中删除节点?
  • 网络运维和网络安全哪个前景好?
  • Python数据可视化 - Matplotlib教程
  • Redis可视化连接工具RedisDesktopManager的下载与安装
  • 基于实例详解pytest钩子pytest_generate_tests动态生成测试的全过程
  • 数据结构与算法之排序算法-选择排序
  • dash SQLite 留言本应用技术实现说明
  • 网络安全之笔记--Linux命令
  • 基于Swift实现拼图游戏
  • SOUI基于Zint生成Code11码
  • centos docker ngnix
  • 【kafka系列】Kafka事务的实现原理
  • Python 基于 OpenCV 的人脸识别上课考勤系统(附源码,部署教程)
  • GenMol:基于SAFE分子表示法的分子生成模型(一)
  • 【D2】神经网络初步学习
  • Rander压力测试监测,更改服务端资源node
  • 【Maven】多module项目优雅的实现pom依赖管理
  • 盲水印、暗水印(Blind Watermark)算法简明教程:算法原理、流程以及基于C/C++ 的代码实现