如何解决迁移到 Flutter 2 后的深色状态栏图标
我最近将 Flutter 版本从 1.22.6 更新到 2.0.2。但是现在在我创建一个新的 flutter 项目(默认计数器应用程序)后,状态栏图标变黑了。在迁移到 2.0.2 之前,它们是轻量级的:
怎么解决?我尝试在 AppBarTheme 中设置灯 statusBarIconBrightness,但它不起作用:
appBarTheme: AppBarTheme(
systemOverlayStyle: SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.light,),
解决方法
你也应该设置 statusBarColor
对于 dart statusBarColor,您应该使用明亮的颜色来提高亮度
AppBarTheme(color: Colors.blue,brightness: Brightness.dark,systemOverlayStyle: SystemUiOverlayStyle(
statusBarColor: Colors.blue
))
,
试试这个
return MaterialApp(
theme: ThemeData(
appBarTheme: Theme.of(context).appBarTheme.copyWith(brightness: Brightness.dark,),...
),...
);