Flutter 状态栏颜色

578 阅读1分钟

使用AppBar

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

/// 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 更改状态栏颜色

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

记得导入 下面这个头文件

import 'package:flutter/services.dart';