Flutter 状态栏完美攻略

1. 沉浸式状态栏

Dart 复制代码
Scaffold(
        extendBodyBehindAppBar: true,
        appBar: AppBar(
          toolbarHeight: 0,
        ),
        body: Container(color:Colors.red)
)

2. 状态栏的背景颜色

Dart 复制代码
Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.transparent,
        ),
        body: Container(color:Colors.red)
)

3. 状态栏的文字颜色

Brightness.light文字黑色
Brightness.dark文字白色

Dart 复制代码
Scaffold(
        appBar: AppBar(
          brightness: Brightness.light,
        ),
        body: Container(color:Colors.red)
)

4. 沉浸式状态栏下的安全区域

Dart 复制代码
Scaffold(
        extendBodyBehindAppBar: true,
        appBar: AppBar(
          toolbarHeight: 0,
        ),
        body: SafeArea(child:Container(color:Colors.red))
)

5. Android机器的状态栏颜色改为透明

默认是带个遮罩的,完全去除:

Dart 复制代码
void main() async {
   runApp(MaterialApp());
    SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(statusBarColor:Colors.transparent);
    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
相关推荐
初遇你时动了情11 小时前
uniapp/flutter中实现苹果IOS 26 毛玻璃效果、跟随滑动放大动画
flutter·ios·uni-app
listhi52015 小时前
Vue.js 3的组合式API
android·vue.js·flutter
起风了___16 小时前
Flutter 多端音频控制台:基于 audio_service 实现 iOS、Android 锁屏与通知中心播放控制
前端·flutter
leinchu19 小时前
Flutter + Codebuddy的坑
flutter
安卓开发者20 小时前
第4讲:理解Flutter的灵魂 - “Everything is a Widget”
开发语言·javascript·flutter
起风了___21 小时前
Flutter 全局音频播放单例实现(附完整源码)——基于 just_audio 的零依赖方案
前端·flutter
DreamMachine21 小时前
Flutter 开发的极简风格音乐播放器
前端·flutter
星释2 天前
鸿蒙Flutter三方库适配指南:08.联合插件开发
flutter·华为·harmonyos
星释2 天前
鸿蒙Flutter三方库适配指南:06.插件适配原理
flutter·华为·harmonyos
小蜜蜂嗡嗡2 天前
【flutter报错:Build failed due to use of deprecated Android v1 embedding.】
android·flutter·embedding