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

后端 未结 17 824
孤城傲影
孤城傲影 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 00:43

    On Android, add the following to onCreate in MainActivity.java, after the call to super.onCreate(savedInstanceState);

    getWindow().setStatusBarColor(0x00000000);

    or you can use the the flutter_statusbarcolor plugin

       changeStatusColor(Color color) async {
        try {
          await FlutterStatusbarcolor.setStatusBarColor(color);
        } on PlatformException catch (e) {
          print(e);
        }
      }
    

    Sample project

提交回复
热议问题