Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a Drawer below status bar in Flutter?

Tags:

flutter

dart

I want to make something like this, but always get this:

https://i.gyazo.com/772cd9a88e08d592690265145bb740d8.png

Scaffold(
  drawer: Drawer(..),
  ..
)

How do I create a Drawer that is not displayed in the status bar?

like image 782
Гордеев Михаил Avatar asked Jun 21 '19 20:06

Гордеев Михаил


People also ask

How do you change the position of the drawer icon in Flutter?

To change the drawer icon in Flutter, add an IconButton widget inside the leading property of the AppBar widget. Inside the IconButton you can set any icon of your choice. Then, inside the onPressed of an IconButton, you can write a method to open the drawer.

How do I customize my status bar in Flutter?

To change status bar color in Flutter, you should set the systemOverlayStyle . Inside the SystemUiOverlayStyle, you can use properties to specify the status bar color as well as the color for the icon and text.


2 Answers

For this kind of scenario, Flutter has the SafeArea widget. This widget will make sure that nothing is rendered e.g. beneath the status bar, i.e. a padding is added.

To apply this to your Drawer, you can simply wrap your Drawer with a SafeArea:

Scaffold(
  drawer: SafeArea(
    child: Drawer(..),
  ),
  ..
)

Screenshot of the drawer

You can also specify if you want to remove some of the padding added by SafeArea using the optional parameters top, bottom, left & right, e.g. SafeArea(bottom: false, ..).

like image 114
creativecreatorormaybenot Avatar answered Sep 25 '22 19:09

creativecreatorormaybenot


Adding the padding: const EdgeInsets.all(0.0), to ListView resolves the issue.

like image 20
Haley Huynh Avatar answered Sep 24 '22 19:09

Haley Huynh