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);
}