• 导包

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

代码截图:

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

项目效果图如下:

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

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

谢谢大家!!!

 

相关文章:

  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2022-03-06
  • 2022-02-09
  • 2022-12-23
猜你喜欢
  • 2021-12-28
  • 2022-12-23
  • 2022-02-09
  • 2021-10-28
  • 2021-09-30
  • 2021-11-19
相关资源
相似解决方案