How to change Status Bar and App Bar color in Flutter?

后端 未结 6 2054
后悔当初
后悔当初 2020-12-14 17:16

I\'m trying to change the color of system status bar to black. The configuration seems to be overridden by the AppBar class. I can achieve what I want by assigning theme: to

6条回答
  •  无人及你
    2020-12-14 17:21

    Both iOS and Android:

    appBar: AppBar(
      backgroundColor: Colors.red, // status bar and navigation bar color
      brightness: Brightness.light, // status bar brightness
    )
    

    Only for Android (More flexibility)

    You can use SystemChrome class to change Status bar and Navigation bar color. First import

    import 'package:flutter/services.dart';
    

    After this, you need to add following lines (better place to put these lines is in your main() method)

    void main() {
      SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
        systemNavigationBarColor: Colors.blue,
        statusBarColor: Colors.pink,
      ));
    }
    

提交回复
热议问题