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

后端 未结 17 823
孤城傲影
孤城傲影 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:48

    While searching for SystemChrome I found this: https://docs.flutter.io/flutter/services/SystemChrome/setSystemUIOverlayStyle.html

    Right above the sample code is a paragraph about AppBar.brightness.

    You should should be able to add an AppBar like this:

    Widget build(BuildContext context) {
        SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
        return new Scaffold(
            appBar: new AppBar(
                title: new Text('Nice title!'),
                brightness: Brightness.light,
            ),
            body: new Container(
            color: UniQueryColors.colorBackground,
            child: new ListView.builder(
               itemCount: 7,
               itemBuilder: (BuildContext context, int index){
                 if (index == 0){
                   return addTopInfoSection();
                 }
               },
            ),
           ),
        );
    }
    

    Heres info about the Brightness

提交回复
热议问题