2

I have a page that I want to have different style, I've tried to change status bar color from example through SystemChrome like this:

class PageState extends State<Page> {
 @override
 void initState() {
 SystemChrome.setSystemUIOverlayStyle(
     SystemUiOverlayStyle(statusBarColor: Colors.white));
 super.initState();
 }
}

And also set up appBar theme:

appBar: AppBar(
    brightness: Brightness.light,
    backgroundColor: Colors.white,
)

But status bar still uses default color from home page.
Also worth mentioning that if I try to change color with this method on home page it works just fine.

HPressure
  • 165
  • 1
  • 9

1 Answers1

1

To set status bar color you should write code in 'build' method, as below example -

   @override
      Widget build(BuildContext context) {
        SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark.copyWith(
            statusBarColor: Color.fromRGBO(41, 167, 77, 50),
            //or set color with: Color(0xFF0000FF)
            statusBarIconBrightness: Brightness.dark));
    return Scaffold();
    }
Nikhat Shaikh
  • 2,395
  • 1
  • 15
  • 19