Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 颤振状态栏颜色与Appbar颜色不相同_Android_Ios_Flutter - Fatal编程技术网

Android 颤振状态栏颜色与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);

我已将状态栏颜色设置为透明。但Appbar仍然不一样

// 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”来解决问题。非常感谢。