当 AppBar 不存在时如何设置状态栏颜色。
我试过了,但没有用。
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
return new Scaffold(
body: new Container(
color: UniQueryColors.colorBackground,
child: new ListView.builder(
itemCount: 7,
itemBuilder: (BuildContext context, int index){
if (index == 0){
return addTopInfoSection();
}
},
),
),
);
}
输出如下所示:
最佳答案
首先,导入 services
包装:
import 'package:flutter/services.dart';
接下来,只需将其放入您应用的构建函数:
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.blue, //or set color with: Color(0xFF0000FF)
));
此外,您可以设置有用的属性,例如:statusBarIconBrightness
, systemNavigationBarColor
或 systemNavigationBarDividerColor
如果您更喜欢 flutter/widget 方式来做同样的事情,请考虑使用 AnnotatedRegion<SystemUiOverlayStyle>
小部件。
value:
属性可以设置为 SystemUiOverlayStyle()
包含如上所示相同属性的对象。
欲了解更多信息,请访问 API Docs
关于dart - Flutter - 如何在 AppBar 不存在时设置状态栏颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50501799/