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

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

    you just have to add this if you want to use as default template in the MaterialApp Theme :

    appBarTheme: AppBarTheme(brightness: Brightness.light)
    

    Result will be like this :

    return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            primarySwatch: Colors.blue,
            appBarTheme: AppBarTheme(brightness: Brightness.light),  <========
            visualDensity: VisualDensity.adaptivePlatformDensity,
          ),
          home: ...,
        );
    

提交回复
热议问题