如何在没有任何第三方插件的情况下更新状态栏图标的颜色?
在我的主题类中,我有一个函数,我正在其中尝试下面的代码,但尚未取得结果:
截至目前的主题代码:
// custom light theme for app
static final customLightTheme = ThemeData.light().copyWith(
brightness: Brightness.light,
primaryColor: notWhite,
accentColor: Colors.amberAccent,
scaffoldBackgroundColor: notWhite,
primaryTextTheme: TextTheme(
title: TextStyle(
color: Colors.black
),
),
appBarTheme: AppBarTheme(
iconTheme: IconThemeData(color: Colors.black),
elevation: 0.0,
)
);
// custom dark theme for app
static final customDarkTheme = ThemeData.dark().copyWith(
brightness: Brightness.dark,
primaryColor: Colors.black,
accentColor: Colors.orange,
scaffoldBackgroundColor: Colors.black87,
primaryTextTheme: TextTheme(
title: TextStyle(
color: Colors.white
),
),
appBarTheme: AppBarTheme(
iconTheme: IconThemeData(color: Colors.white),
elevation: 0.0,
),
);
主题变换器代码:
// set theme for the app
setTheme(ThemeData theme) {
_themeData = theme;
if(_themeData == ThemeChanger.customLightTheme){
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(
statusBarColor: Colors.white,
systemNavigationBarColor: Colors.white,
systemNavigationBarDividerColor: Colors.black,
systemNavigationBarIconBrightness: Brightness.dark,
),
);
} else {
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(
statusBarColor: Colors.blue,
systemNavigationBarColor: Colors.blue,
systemNavigationBarDividerColor: Colors.red,
systemNavigationBarIconBrightness: Brightness.light,
),
);
}
notifyListeners();
}
这不是我想要的,因为我不想要第三方解决方案。
状态栏中图标的颜色(Flutter) https://stackoverflow.com/questions/57974569/icons-color-in-status-bar-flutter
目前,我在主题更改时得到白色/浅色主题的黑色图标,以及深色/黑色主题的黑色图标(应该是白色图标)。休息一切正常。