如何在Flutter中使Android状态栏亮起 [英] How to make Android status bar light in Flutter

查看:180
本文介绍了如何在Flutter中使Android状态栏亮起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所示,这与Flutter有关。

As the title suggests, this is about Flutter.

有什么方法可以将Android状态栏切换为亮模式,从而使状态栏中的图标显示为深色?例如查看图片。

Is there any way to switch Android status bar to light mode so that the icons in status bar show up dark? See picture for example.

我尝试了以下可能的解决方案,但没有一个起作用-

I tried following possible solutions but none of them worked -

// 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

对此的支持是在工作中- https://github.com/flutter/flutter/issues/17231

The support for this is in works - https://github.com/flutter/flutter/issues/17231

推荐答案

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

The Flutter team have now added support for light/dark status bar control. To add, import this:

import 'package:flutter/services.dart';

然后将其添加到应用的构建函数中:

Then add this in your App's build function:

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

这篇关于如何在Flutter中使Android状态栏亮起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆