Flutter 状态栏颜色

使用AppBar

修改 AppBar中的 brightness属性 是个 枚举 有 Dark, 和 Brightness 两个属性bash

/// Describes the contrast of a theme or color palette.
enum Brightness {
  /// The color is dark and will require a light text color to achieve readable
  /// contrast.
  ///
  /// For example, the color might be dark grey, requiring white text.
  dark,

  /// The color is light and will require a dark text color to achieve readable
  /// contrast.
  ///
  /// For example, the color might be bright white, requiring black text.
  light,
}
复制代码

未使用AppBar的状况

未使用AppBar 可使用 SystemUiOverlayStyle 更改状态栏颜色ui

return AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle.dark,
      child: Material(child: Scaffold(body: loginMain(),),),
    );
复制代码

记得导入 下面这个头文件spa

import 'package:flutter/services.dart';
复制代码