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

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.dtcms.com/a/25727.html

相关文章:

  • Redux中间件redux-thunk和redux-saga的具体区别是什么?
  • spring cloud和dubbo的特点和优劣势
  • 【Linux】【网络】Reactor模式
  • tailwindcss学习01
  • JavaScript中数组的常用方法
  • 【从0做项目】Java搜索引擎(6) 正则表达式鲨疯了优化正文解析
  • 深入剖析Spring MVC
  • CMake技术细节:解决未定义,提供参数
  • 从零到一实现微信小程序计划时钟:完整教程
  • 【ClickHouse 特性及应用场景】
  • ubuntu 执行 sudo apt-get update 报错
  • redis7 for windows的安装教程
  • vue 接口传formdata
  • 基于Java+Swing+Mysql实现旅游管理信息系统
  • Promise异步编程
  • 【阮一峰】6.对象
  • 【阮一峰】8.类
  • 如何写出优秀的测试用例?
  • QT基础七、用纯代码编写界面
  • 使用Keras构建图像分类模型的入门指南
  • ssm019基于ssm社区文化宣传网站+jsp(源码+包运行+LW+开题报告+任务书+技术指导)
  • 第一期——LeetCode 26删除有序数组中的重复项
  • Vulnhub中的Lupinone
  • Flutter:K线图
  • 鸿蒙(HarmonyOS)开发学习路线指南:从零到实战
  • Arduino IDE编程ESP32-C3的Flash选项
  • 轻松搭建本地大语言模型(一)Ollama安装与使用
  • 【进阶】redis篇
  • 组合模式详解(Java)
  • Linux nftables 命令使用详解