正如标题所示,这是关于 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
对此的支持正在进行中 - https://github.com/flutter/flutter/issues/17231
最佳答案
Flutter 团队现在添加了对亮/暗状态栏控制的支持。要添加,请导入:
import 'package:flutter/services.dart';
然后在你的 App 的构建函数中添加这个:
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark.copyWith(
statusBarIconBrightness: Brightness.dark
));
https://stackoverflow.com/questions/49179175/