How can I simply set the height of the AppBar
in Flutter?
The title of the bar should be staying centered vertically (in that AppBar
).
How can I simply set the height of the AppBar
in Flutter?
The title of the bar should be staying centered vertically (in that AppBar
).
You can use PreferredSize:
At the time of writing this, I was not aware of
PreferredSize
. Cinn's answer is better to achieve this.You can create your own custom widget with a custom height:
If you are in Visual Code, Ctrl + Click on AppBar function.
And edit this piece.
Difference of height!
You can use
PreferredSize
andflexibleSpace
for it:This way you can keep the
elevation
ofAppBar
for keeping its shadow visible and have custom height, which is what I was just looking for. You do have to set the spacing inSomeWidget
, though.In addition to @Cinn's answer, you can define a class like this
or this way
and then use it instead of standard one