Flutter - How to set status bar color when AppBar not present

后端 未结 17 820
孤城傲影
孤城傲影 2020-12-07 23:56

How to set status bar color when AppBar not present.

I have tried this but not working.

Widget build(BuildContext context) {
    SystemChrome.setSys         


        
17条回答
  •  不知归路
    2020-12-08 01:00

    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, // navigation bar color
        statusBarColor: Colors.pink, // status bar color
      ));
    }
    

提交回复
热议问题