更改状态栏颜色仅适用于某些页面

时间:2019-01-12 05:32:14

标签: dart flutter

我试图将应用程序的状态栏颜色更改为深色

我遵循了这个How to change status bar color in Flutter?

并这样做:

   SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);

但是由于某些原因,它仅适用于某些页面,而其他页面仍然是白色的!

例如此页面:

  @override
  Widget build(BuildContext context) {
  final theme = Theme.of(context).copyWith(unselectedWidgetColor: Colors.red);
  Animation opacityAnimation =
  Tween(begin: 0.0, end: 1.0).animate(animationController);
  return new Directionality(
  textDirection: TextDirection.rtl,
  child: new Theme(
    data: theme,
    child: new Scaffold(
        key: scaffoldKey,
        drawer: globals.drawer(context),
        appBar: new AppBar(
          leading: IconButton(
            icon: Icon(
              CustomFont.burger,
              color: Color(0xff474747),
            ),
            onPressed: () {
              scaffoldKey.currentState.openDrawer();
            },
          ),
          centerTitle: true,
          elevation: 0.0,
          bottom: PreferredSize(
              child: Container(
                color: Color(0xff2CB57D),
                height: 0.20,
              ),
              preferredSize: Size.fromHeight(0.20)),
          backgroundColor: Colors.white,
          title: new Image.asset(
            'assets/appbar-icon.png',
            width: 55.0,
            height: 27.0,
          ),
          actions: <Widget>[
            IconButton(
              icon: Icon(
                CustomFont.home,
                color: Color(0xff474747),
              ),
              onPressed: () {
                globals.goToHome(context);
              },
            ),

          ],
        ),
        body: ......
  ),
);
}

无论我是否更改,此页面的颜色始终为白色!

为什么会这样?以及如何解决?

0 个答案:

没有答案
相关问题