Android 颤振状态栏颜色与Appbar颜色不相同
我已将状态栏颜色设置为透明。但Appbar仍然不一样Android 颤振状态栏颜色与Appbar颜色不相同,android,ios,flutter,Android,Ios,Flutter,我已将状态栏颜色设置为透明。但Appbar仍然不一样 // on main method if (Platform.isAndroid) { SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(statusBarColor: Colors.transparent); SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
// on main method
if (Platform.isAndroid) {
SystemUiOverlayStyle systemUiOverlayStyle =
SystemUiOverlayStyle(statusBarColor: Colors.transparent);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
// on a widget build method
Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
brightness: Brightness.light,
centerTitle: true,
backgroundColor: Colors.white,
elevation: 0,
title: Text('发现', style: BMTextStyle.black_56),
),
body: SafeArea(
top: false,
child: TabBarView(controller: _controller, children: <Widget>[
_buildPageContentAccordingIndex(0),
_buildPageContentAccordingIndex(1),
]),
),
),
//关于main方法
if(Platform.isAndroid){
SystemUiOverlayStyle SystemUiOverlayStyle=
SystemUIOverlyStyle(statusBarColor:Colors.transparent);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
//关于小部件构建方法
脚手架(
背景颜色:Colors.white,
appBar:appBar(
亮度:亮度,亮度,
标题:对,
背景颜色:Colors.white,
海拔:0,
标题:文本('发现', 样式:BMTextStyle.黑色(56),
),
正文:安全区(
上图:错,
子项:选项卡视图(控制器:\控制器,子项:[
_buildPageContentAccordingIndex(0),
_buildPageContentAccordingIndex(1),
]),
),
),
结果是状态栏的颜色看起来是灰色的,而脚手架是白色的。那么,如何使它们相同呢?谢谢大家! 您希望在每个
有状态小部件(基本上是每个屏幕)内使用AnnotatedRegion
,以调整状态栏。我以前用过其他方法,但AnnotatedRegion确保在使用Navigator.pop(上下文)返回此屏幕时,状态栏再次更新其样式。只需使用AnnotatedRegion
将脚手架包裹起来,然后将值设置为SystemUIOverlyStyle
变量,如下所示:
@覆盖
小部件构建(构建上下文){
SystemUIOverlyStyle\u statusBarStyle=SystemUIOverlyStyle(
statusBarColor:Colors.transparent,
Status Baricon亮度:亮度。暗,
);
德雷吉翁酒店(
值:_statusBarStyle,
孩子:脚手架(
背景颜色:Colors.white,
appBar:appBar(
亮度:亮度,亮度,
标题:对,
背景颜色:Colors.white,
海拔:0,
标题:文本('发现', 样式:BMTextStyle.黑色(56),
),
正文:安全区(
上图:错,
子项:选项卡视图(控制器:\控制器,子项:[
_buildPageContentAccordingIndex(0),
_buildPageContentAccordingIndex(1),
]),
),
),
);
}
希望这有帮助。终于解决了。我的小部件是使用PageView构建的,没有appbar,因此在safeare中使用“top:false”来解决问题。非常感谢。