这篇文章主要为大家介绍了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的资料请关注编程学习网其它相关文章!
本文标题为:Flutter SystemChrome控制应用程序的系统级别行为
基础教程推荐
- Android中的webview监听每次URL变化实例 2023-01-23
- Android多返回栈技术 2023-04-15
- Android开发使用RecyclerView添加点击事件实例详解 2023-06-15
- IOS 播放系统提示音使用总结(AudioToolbox) 2023-03-01
- 解决Android Studio突然不显示logcat日志的问题 2023-02-04
- android studio按钮监听的5种方法实例详解 2023-01-12
- Flutter绘图组件之CustomPaint使用详解 2023-05-12
- iOS开发教程之XLForm的基本使用方法 2023-05-01
- Flutter手势密码的实现示例(附demo) 2023-04-11
- IOS应用内跳转系统设置相关界面的方法 2022-11-20
