Flutter SystemChrome控制应用程序的系统级别行为
SystemChrome
SystemChrome 是 Flutter 提供的一个类,用来控制应用程序的系统级别行为,如设置全屏,状态栏等。
- 设置状态栏透明
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark, // 状态栏图标亮色
),
);
通过 setSystemUIOverlayStyle 设置状态栏的透明背景和黑色图标。
- 修改状态栏文字颜色为白色
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle.dark.copyWith(
statusBarIconBrightness: Brightness.light,
),
);
通过 setSystemUIOverlayStyle 将状态栏的文字颜色修改为白色。
- 隐藏底部导航栏
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.top]);
通过 setEnabledSystemUIOverlays 隐藏底部导航栏,只显示状态栏。
- 禁止横屏
SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]);
通过 setPreferredOrientations 禁止屏幕横屏,只允许竖屏。
- 设置全屏模式
SystemChrome.setEnabledSystemUIOverlays([]);
通过 setEnabledSystemUIOverlays 设置全屏模式,即隐藏状态栏、设置面板和导航栏。
- 设置状态栏高亮模式
SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle.light, );
通过 setSystemUIOverlayStyle 将状态栏的图标和文字设置为浅色。
以上就是Flutter SystemChrome用来控制应用程序的系统级别行为的详细内容,更多关于Flutter SystemChrome的资料请关注脚本之家其它相关文章!
相关文章
20.5 语音合成(百度2016年2月29日发布的tts引擎)
编写手机App时,有时需要使用文字转语音(Text to Speech)的功能,比如开车时阅读收到的短信、导航语音提示、界面中比较重要的信息通过语音强调2016-03-03
Android用SharedPreferences实现登录注册注销功能
这篇文章主要为大家详细介绍了Android用SharedPreferences实现登录注册注销功能,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2022-04-04
Android开发之计算器GridLayout布局实现方法示例
这篇文章主要介绍了Android开发之计算器GridLayout布局实现方法,结合实例形式分析了Android计算器界面布局及表达式计算相关操作技巧,需要的朋友可以参考下2019-03-03


最新评论