[英]Flutter: Change Statusbar Text Color not working properly
Almost all the Q/A referred on Stackoverflow related to the same topic but didn't get proper solutions. Stackoverflow 上提到的几乎所有 Q/A 都与同一主题相关,但没有得到适当的解决方案。
Main Question: My app having the primary color blue and I want to set Statusbar Text Color white.主要问题:我的应用程序的原色为蓝色,我想将状态栏文本颜色设置为白色。
What I have tried:我试过的:
Using SystemChrome: (Using the following code, It's just changing the color of status bar text in the first screen only, other screens are having blue/black combination background/foreground.)使用SystemChrome:(使用以下代码,它只是在第一个屏幕中更改状态栏文本的颜色,其他屏幕具有蓝/黑组合背景/前景。)
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( statusBarColor: MaterialColor(0xFF084775, color), // status bar color statusBarBrightness: Brightness.light,//status bar brightness statusBarIconBrightness:Brightness.light, //status barIcon Brightness ));
Screenshots:截图:
Splash Screen:启动画面:
Dashboard Screen:仪表板屏幕:
Using ThemeData : (This method gives the same result as the above screenshot).使用ThemeData :(此方法的结果与上面的屏幕截图相同)。
theme: ThemeData( brightness: Brightness.light, // ADDED THIS LINE.. primarySwatch: MaterialColor(0xFF084775, color), accentColor: Color(0xffe46b10), unselectedWidgetColor: Colors.grey, fontFamily: 'SourceSansPro', ),
I have also checked github issue link but not worked for me.我还检查了github 问题链接,但对我不起作用。
I just need to change Statusbar Text Color to White.我只需要将状态栏文本颜色更改为白色。 Any help?
有什么帮助吗?
To apply for all appBar use申请所有 appBar 使用
return MaterialApp(
theme: ThemeData(
appBarTheme: Theme.of(context).appBarTheme.copyWith(brightness: Brightness.dark),
),
debugShowCheckedModeBanner: false,
// home: InvoiceList(),
home: widget());
I hope it will works.我希望它会起作用。
Thank you.谢谢你。
As of Flutter 2截至 Flutter 2
return MaterialApp(
theme: ThemeData(
appBarTheme: Theme.of(context)
.appBarTheme
.copyWith(systemOverlayStyle: SystemUiOverlayStyle.light)),
debugShowCheckedModeBanner: false,
home: widget());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.