flutter 设置状态栏的背景与颜色

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([]); //隐藏状态栏
    }
}

代码截图:

 

项目效果图如下:

谢谢大家!!!

 

posted @ 2020-08-29 17:50  学富五车  阅读(1777)  评论(0编辑  收藏  举报