Flutter 修改状态栏字体颜色的3种方案

4,053 阅读1分钟

1. 通过 SystemChrome 修改

  SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark); // SystemUiOverlayStyle.light

2. 通过 AnnotatedRegion 修改

  @override
  Widget build(BuildContext context) {
    return AnnotatedRegion(
      value: SystemUiOverlayStyle.dark, // SystemUiOverlayStyle.light
      child: Container(),
    );
  }

3. 通过 AppBar 修改

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        systemOverlayStyle: SystemUiOverlayStyle.dark, // SystemUiOverlayStyle.light
      ),
      body: Container(),
    );
  }