加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如何在Flutter中使Android状态栏亮起

发布时间:2020-12-14 14:52:17 所属栏目:百科 来源:网络整理
导读:正如标题所示,这是关于Flutter的. 有没有办法将Android状态栏切换到灯光模式,以便状态栏中的图标显示为黑暗?见图片. 我尝试了可能的解决方案,但没有一个工作 – // main.dartappBar: new AppBar( brightness: Brightness.light,backgroundColor: Colors.whi
正如标题所示,这是关于Flutter的.

有没有办法将Android状态栏切换到灯光模式,以便状态栏中的图标显示为黑暗?见图片.

我尝试了可能的解决方案,但没有一个工作 –

// main.dart
appBar: new AppBar(
      brightness: Brightness.light,backgroundColor: Colors.white,),// MainActivity.kt
// Following 2 lines do change the color of status and nav bars
window.statusBarColor = 0x00000000
window.navigationBarColor = 0x00000000

// This seems to have no effect. Icons are still white.
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR

enter image description here

UPDATE

对此的支持正在进行中 – https://github.com/flutter/flutter/issues/17231

解决方法

Flutter团队现在增加了对明/暗状态栏控制的支持.要添加,请导入:

import 'package:flutter/services.dart';

然后在App的构建函数中添加:

SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark.copyWith(
  statusBarIconBrightness: Brightness.dark
));

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读