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
or systemNavigationBarDividerColor
如果您更喜欢颤动/小部件做同样的事情的方式,考虑使用AnnotatedRegion<SystemUiOverlayStyle>
小部件。
The value:
属性可以设置为SystemUiOverlayStyle()
包含与上面所示相同属性的对象。
欲了解更多信息,请前往API Docs https://api.flutter.dev/flutter/services/SystemChrome/setSystemUIOverlayStyle.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)