How can I get the height of an AppBar in Flutter?
 I am using the MarialApp Widget ('package:flutter/material.dart').
 I have the height of my Context and would like to deduct the height of the appbar.
final double height = MediaQuery.of(context).size.height; 
                Firstly declare the AppBar widget that you will use in your Scaffold. Now you can get the height of your appBar using its preferred size: double height = appBar.
kToolbarHeight top-level constant Null safetyThe height of the toolbar component of the AppBar.
A widget with a preferred size. This widget does not impose any constraints on its child, and it doesn't affect the child's layout in any way. It just advertises a preferred size which can be used by the parent. Parents like Scaffold use PreferredSizeWidget to require that their children implement that interface.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With