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

前端之家收集整理的这篇文章主要介绍了如何在Flutter中使Android状态栏亮起前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
正如标题所示,这是关于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
));

猜你在找的Flutter相关文章