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);
}
相关推荐
玫瑰花开一片一片28 分钟前
Flutter IOS 真机 Widget 错误。Widget 安装后系统中没有
flutter·ios·widget·ios widget
hepherd2 小时前
Flutter 环境搭建 (Android)
android·flutter·visual studio code
bst@微胖子19 小时前
Flutter之路由和导航
flutter
亚洲小炫风20 小时前
flutter 中各种日志
前端·flutter·日志·log
louisgeek1 天前
Flutter 动画之 Implicit 隐式动画
flutter
勤劳打代码1 天前
游刃有余 —— Isolate 轻量化实战
flutter·github·dart
RichardLai881 天前
[Flutter 基础] - Flutter基础组件 - Text
android·flutter
Ya-Jun2 天前
常用第三方库精讲:cached_network_image图片加载优化
android·flutter
WDeLiang2 天前
Flutter 环境搭建
flutter·ios·visual studio code
程一个大前端2 天前
【Flutter高效开发】GetX指南:一文学会状态管理、路由与依赖注入
flutter