Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to remove screen content from StatusBar in Flutter/Dart?

When I have an AppBar on my screen, it looks like this:

enter image description here

But I don’t need AppBar so I removed it. As a result my screen looks like this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

As you can see, the top of my screen is in the StatusBar (where there are clock, Internet connection icon, and so on).

Please help me change my code so that my screen starts right after the StatusBar.

Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
        home: Container(
            child: Scaffold(
        // appBar: AppBar (title: const Text(_title)),
              body: const MainWidget(),
      ),
    )
    );
  }

Thanks in advance.

Edit 1. Why doesn’t this work for the Container case? I had this code on another screen:

@override
  Widget build(BuildContext context) {
    return Container(
      height: MediaQuery.of(context).size.height,
...

I changed it to this:

@override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Container(
      height: MediaQuery.of(context).size.height,
...

But nothing has changed. Why?

>Solution :

Wrap your scaffold body with SafeArea widget

  @override
  Widget build(BuildContext context) {
    return SafeArea(

For your case, do it on home or scaffold.

home: SafeArea(

More about SafeArea

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading