flutter - Flutter:更改状态栏文本颜色无法正常工作
问题描述
Stackoverflow 上提到的几乎所有 Q/A 都与同一主题相关,但没有得到适当的解决方案。
主要问题:我的应用程序的原色为蓝色,我想将状态栏文本颜色设置为白色。
我试过的:
使用SystemChrome:(使用以下代码,它只是在第一个屏幕中更改状态栏文本的颜色,其他屏幕具有蓝/黑组合背景/前景。)
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( statusBarColor: MaterialColor(0xFF084775, color), // status bar color statusBarBrightness: Brightness.light,//status bar brightness statusBarIconBrightness:Brightness.light , //status barIcon Brightness ));
截图:
启动画面:
仪表板屏幕:
使用ThemeData:(此方法的结果与上面的屏幕截图相同)。
theme: ThemeData( brightness: Brightness.light, // ADDED THIS LINE.. primarySwatch: MaterialColor(0xFF084775, color), accentColor: Color(0xffe46b10), unselectedWidgetColor: Colors.grey, fontFamily: 'SourceSansPro', ),
我还检查了github 问题链接,但对我不起作用。
我只需要将状态栏文本颜色更改为白色。有什么帮助吗?
解决方案
申请所有 appBar 使用
return MaterialApp(
theme: ThemeData(
appBarTheme: Theme.of(context).appBarTheme.copyWith(brightness: Brightness.dark),
),
debugShowCheckedModeBanner: false,
// home: InvoiceList(),
home: widget());
我希望它会起作用。
谢谢你。
推荐阅读
- arrays - 如何将数据创建和更新为保存在各个行中的数组
- android - 在 HomeFragment 上的应用程序中添加日问候语
- vb.net - “由于保护级别,它可能无法访问”
- python - 'middle' 名称为 'None' ,其中 None 是预期的
- javascript - 将道具传递给反应中的函数
- oracle - 在 Oracle PLSQL 函数的输出过程中出现逗号问题
- python - 尝试使用循环取出某些字符
- python - pytz DST 的问题
- c - 在C中写入文件后,循环不会退出
- sql-server - 检查边缘表(Graph DB)中是否存在记录[以可重用的方式]