flutter 设置状态栏的背景与颜色
-
导包
import 'dart:io';
import 'package:flutter/services.dart';
-
在main()函数中添加以下函数,
void main() {
runApp(new MyApp());
if(Platform.isAndroid){ // 设置状态栏背景及颜色
SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(statusBarColor: Colors.transparent);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
// SystemChrome.setEnabledSystemUIOverlays([]); //隐藏状态栏
}
}
代码截图:
项目效果图如下:
谢谢大家!!!