Flutter 透明状态栏及字体颜色的设置方法
作者:哇咔 哇咔 时间:2021-12-09 21:28:30
注:底色透明是否生效与android版本有关,版本过低设置无效
1.在main.dart内设置
void main(){
runApp(new MyApp());
if (Platform.isAndroid) {
//设置Android头部的导航栏透明
SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(
statusBarColor: Colors.transparent, //全局设置透明
statusBarIconBrightness: Brightness.light
//light:黑 * 标 dark:白 * 标
//在此处设置statusBarIconBrightness为全局设置
);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
}
2.单页面设置
appBar: AppBar(
title: new Text(''),
elevation: 0,
brightness: Brightness.dark, //设置为白色字体
),
注:设置AppBar之后,单独在build内设置这行代码会失效 SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);
ps:下面看下Flutter修改状态栏颜色以及字体颜色
Flutter沉浸式状态栏
void main() {
runApp(MyApp());
if (Platform.isAndroid) {
// 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后,是为了在渲染后进行set赋值,覆盖状态栏,写在渲染之前MaterialApp组件会覆盖掉这个值。
SystemUiOverlayStyle systemUiOverlayStyle =
SystemUiOverlayStyle(statusBarColor: Colors.transparent);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
}
Flutter修改状态栏字体颜色
使用AnnotatedRegion包裹Scaffold,可以使得状态栏颜色改变,有dark和light两种
@override
Widget build(BuildContext context) {
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle.light,
child: Material(child:Scaffold(),),);
}
来源:https://blog.csdn.net/klousYG/article/details/105845683
标签:flutter,状态栏,字体颜色
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java建造者模式构建复杂对象的最佳实践
2021-06-27 10:07:16
![](https://img.aspxhome.com/file/2023/8/61808_0s.png)
WPF+SkiaSharp实现自绘拖曳小球
2023-03-25 01:31:14
![](https://img.aspxhome.com/file/2023/6/91286_0s.gif)
Android线程间通信Handler源码详解
2021-12-31 07:04:10
![](https://img.aspxhome.com/file/2023/7/88677_0s.png)
SpringIOC框架的简单实现步骤
2021-10-28 21:44:35
springboot更新配置Swagger3的一些小技巧
2023-08-28 06:31:43
C# 数独求解算法的实现
2022-04-04 18:48:57
![](https://img.aspxhome.com/file/2023/2/68102_0s.png)
浅谈MyBatis3 DynamicSql风格语法使用指南
2023-11-25 13:05:06
Mybatis 入参类型方式全面详解
2023-10-16 20:03:40
spring基础概念AOP与动态代理理解
2022-01-29 20:55:13
基于springboot+vue实现垃圾分类管理系统
2023-04-17 08:39:11
![](https://img.aspxhome.com/file/2023/2/86862_0s.jpg)
JDK1.8下载、安装和环境配置超详细教程(最新最完整)
2022-07-22 12:58:34
![](https://img.aspxhome.com/file/2023/5/62805_0s.jpg)
Java动态获取实现某个接口下所有的实现类对象集合
2023-04-01 14:43:20
C#四舍五入用法实例
2021-07-20 02:49:20
spring配置文件解析失败报”cvc-elt.1: 找不到元素 ''beans'' 的声明”异常解决
2021-07-01 12:45:52
![](https://img.aspxhome.com/file/2023/9/89639_0s.png)
java 基础之JavaBean属性命名规范问题
2022-10-09 05:44:22
探讨C#中Dispose方法与Close方法的区别详解
2023-01-24 03:59:55
MyBatis 中 SqlMapConfig 配置文件详解
2023-10-19 21:23:01
Java实战项目之校园跑腿管理系统的实现
2023-11-11 10:29:09
![](https://img.aspxhome.com/file/2023/9/104009_0s.jpg)
java控制线程运行
2023-03-05 15:35:30
SpringBoot整合Mybatis实现CRUD
2022-01-10 09:26:45
![](https://img.aspxhome.com/file/2023/5/84765_0s.png)