flutter - 在 Flutter 中仅更改状态栏的颜色
问题描述
我有这样的布局,我想只更改状态栏的颜色,因为我没有使用过 Appbar。
这是我用于此的代码:
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Column(children: [
Container(
color: Colors.green,
padding: EdgeInsets.all(15),
child: TextFormField(
cursorColor: Colors.green,
decoration: InputDecoration(
contentPadding:
EdgeInsets.symmetric(vertical: 0.0, horizontal: 10.0),
hintText: 'Search a product',
fillColor: Colors.white,
filled: true,
prefixIcon: Visibility(
visible: true,
child: Icon(
Icons.search,
color: Colors.grey.shade900,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(6),
borderSide: BorderSide(
color: Colors.grey.shade200, width: 1.5
)
),
)
),
),
//AND OTHER ELEMENTS
],),
),
);
}
}
我想将状态栏的颜色更改为深绿色
解决方案
您可以在您的应用程序栏中直接在 MaterialApp 栏主题中提供它
在 Material 应用全局主题中
MaterialApp(
theme: ThemeData(
appBarTheme: AppBarTheme(
brightness: Brightness.dark,
backwardsCompatibility: false,
systemOverlayStyle:
SystemUiOverlayStyle(statusBarColor: Colors.orange),
)
statusBarColor
是您要更改的 topBar 的颜色。设置很重要,backwardsCompatibility: false
因为它不起作用。
推荐阅读
- android - 如何打开 jetpack DataStore 文件 (.preferences_pb)
- f# - 为什么在词法分析器规范中对换行符和空格的处理不同?
- php - 如何通过包含在数组中的 meta_key 对 WordPress 帖子进行排序?
- python - CSV 文件被 pandas 误读
- python - 将新值附加到 Python 字典中的同一键
- makefile - 使用标志 $(@:.o=.d) 后生成文件依赖错误
- java - Apache Camel 调度到本地 JaxRs 资源实现
- javascript - 如何编写异步函数以在 javascript 中查找字符串枚举?
- java - 我在从 Json 输出中获取数据时遇到问题
- python - 根据熊猫规则改变数量的Pythonic方式?