Remove AppBar but keeping StatusBar in Flutter

Issue

How I can have a custom color for my StatusBar without the AppBar?

To customize the StatusBar color I used this code:

appBar: AppBar(
    backgroundColor: Colors.teal
)

If I remove appbar I can’t customize the StatusBar. How I can do this?

How can I remove the AppBar but keeping the StatusBar?

Solution

Add this in your main.dart‘s main method file after the runApp method

SystemChrome.setSystemUIOverlayStyle(
        SystemUiOverlayStyle(statusBarColor: <YOUR STATUS BAR COLOR>));

Like this:

void main(){
 runApp(MyApp());
SystemChrome.setSystemUIOverlayStyle(
            SystemUiOverlayStyle(statusBarColor: <YOUR STATUS BAR COLOR>));
}

If you are using SafeArea then you need to set it’s top property to false.

Answered By – Sameer Carpenter

Leave a Comment