[英]how to apply color to statusbar in flutter?
i want to change statusbar color to white.我想将状态栏颜色更改为白色。 but it loos like gray.
但它看起来像灰色。 i use safeArea, and not use appbar.
我使用safeArea,而不是使用appbar。 so i wrap safearea in Container to set color to white.
所以我将安全区域包装在容器中以将颜色设置为白色。
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white, // statusbar color
child: SafeArea(
child: Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
body: Column(
children: [
appBarContainer(),
Expanded(
child: GetX<PostDetailController>(
builder: (controller) {
return Scrollbar(
child: ListView.builder(
itemBuilder: (context, index) {
return postContainer(context, controller);
},
itemCount: controller.post.length,
));
},
),
)
],
),
)),
);
}
}
refer below code and add this in void main()
before runApp
请参考下面的代码并将其添加到
void main()
之前runApp
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(
statusBarColor: Colors.transparent, // status bar color
),
);
void main() {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.red));
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
}
this how you can add color to status bar这是如何为状态栏添加颜色的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.