简体   繁体   English

如果使用 sliver 应用栏,如何设置状态栏颜色

[英]How to set status bar color if using sliver app bar

As I am having sliver app bar in my screen, I am not using AppBar() widget.由于我的屏幕上有条形应用栏,因此我没有使用 AppBar() 小部件。 So by default the status bar color is white.所以默认状态栏颜色是白色的。

Is there a way to change the color of status bar from sliver.有没有办法从条子更改状态栏的颜色。

在此处输入图片说明

Below code works for Android as expected, but not for iOS.下面的代码按预期适用于 Android,但不适用于 iOS。

SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
    statusBarColor: kPrimaryColor,
  ));

If using app bar to change the color, then sliver breaks如果使用应用栏更改颜色,则条子会断裂在此处输入图片说明

add color what you need and set pinned to false添加您需要的color并将pinned设置为 false

SliverAppBar(
      backgroundColor: Colors.blue,
      expandedHeight: 160.0,
      pinned: false,
      stretch: false,
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM