How to get AppBar height in Flutter? How to get AppBar height in Flutter? dart dart

How to get AppBar height in Flutter?


This is not an ideal way, I think, but it will work.

Firstly declare the AppBar widget that you will use in your Scaffold.

Widget demoPage() {  AppBar appBar = AppBar(    title: Text('Demo'),  );  return Scaffold(    appBar: appBar,    body: /*    page body    */,  );}

Now you can get the height of your appBar using its preferredSized:

double height = appBar.preferredSize.height;

You can use this height to reduce from the screen height.

final double height = MediaQuery.of(context).size.height;


you can use this :

var height = AppBar().preferredSize.height;

this way is very sample and easy


There is a constant for the normal toolbar height: kToolbarHeight