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);
}
相关推荐
带带弟弟学爬虫__6 分钟前
dyAPP数据采集-个人主页、发布、搜索、评论
服务器·python·算法·flutter·java-ee·django
icc_tips36 分钟前
Flutter runAppAsync() 详解:干净的异步应用启动
前端·flutter
恋猫de小郭2 小时前
Android 发布全新性能分析器,实用性和性能大升级
android·前端·flutter
恋猫de小郭3 小时前
Flutter 3.44 发布啦,超级大版本更新!!!
android·flutter·ios
张3蜂3 小时前
Flutter macOS 安装文档
flutter·macos
Swuagg3 小时前
Flutter 架构实践:从 0 到 1 构建智能眼镜应用
flutter·架构
天天开发3 小时前
Flutter开发者该掌握的iOS隐私审核政策
flutter·ios·cocoa
leazer21 小时前
Flutter Windows 构建失败:.plugin_symlinks 符号链接异常的排查与修复
windows·flutter
小蜜蜂嗡嗡2 天前
flutter image_cropper截图控件布局顶到状态栏中问题
flutter
程序员老刘2 天前
跨平台开发地图:大厂统一底层,五月框架大乱斗谁在干实事?| 2026年5月
flutter·客户端