[英]status bar doesn't change background color in flutter
I have two pages first one have white status bar and the second page has gray status bar but when I move from one to another page the second page takes first status bar color??我有两个页面,第一个页面有白色状态栏,第二个页面有灰色状态栏,但是当我从一个页面移动到另一个页面时,第二个页面采用第一个状态栏颜色?
NOTE: when I run the second page from main function it takes the right color注意:当我从主 function 运行第二页时,它采用正确的颜色
I use this for status bar:我将它用于状态栏:
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark.copyWith(
statusBarColor: Color(0xffF6F6F6),
statusBarBrightness: Brightness.dark
));
what is the reason for this?这是什么原因?
Try out this:-试试这个: -
Wrap your MaterialApp with below code in main.dart class:-在 main.dart class 中用以下代码包装您的 MaterialApp:-
AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
statusBarColor: Colors.transparent, //set as per your status bar color
systemNavigationBarColor: Colors.black, //set as per your navigation bar color
statusBarIconBrightness: Brightness.dark, //set as per your status bar icons' color
systemNavigationBarIconBrightness: Brightness.dark,
),
child: MaterialApp(
And if you want change appbar color of whole app then try out below如果您想更改整个应用程序的应用栏颜色,请在下面尝试
theme: Theme.of(context).copyWith(
appBarTheme: Theme.of(context)
.appBarTheme
.copyWith(brightness: Brightness.light),
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.