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

后端 未结 6 2052
后悔当初
后悔当初 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:30

    Please read this flutter package. To set status bar text as black, you can set FlutterStatusbarcolor.setStatusBarWhiteForeground(false). you need to have this line of code in didChangeAppLifecycleState method with resume state so that when you go to other application and come back, the status bar text color are set to your initial setup.

    Also, you need to set the your AppBar's TextTheme. like following.

    Widget build(BuildContext context) {
    FlutterStatusbarcolor.setStatusBarWhiteForeground(false);
    return MaterialApp(
        title:// title goes here
        theme:// your theme goes here
        home:   Scaffold(
          appBar: AppBar(
                          backgroundColor: Colors.white,
                          title: _loadAppBarTitle(),
                          textTheme: Theme.of(context).textTheme),
          body: //body's goes here
      );
    );
    

    Hopefully, this one can help somebody who has the similar problem with me.

提交回复
热议问题