To get Bottom Padding use
``` final bottomPadding = MediaQuery.of(context).padding.bottom; ```To get Top Padding use
``` final topPadding = MediaQuery.of(context).padding.top; ```If you want to get the height of the App Bar which is used as a flutter Material component
``` AppBar appBar = new AppBar(); appBar.preferredSize.height; ```SafeArea widget's bottom and top properties by default are set to true. Setting 'bottom: false' and 'top: false' returns the actual SafeArea's bottom and top padding value.
``` return SafeArea( top: false, bottom: false, child: Scaffold( body: SingleChildScrollView( child: Container( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, ... ```To get only Safe Area's height, try to access MediaQuery somewhere before adding SafeArea in the widget tree. This way you will get MediaQuery.of(context).padding
with some value instead of EdgeInsets.zero
. Padding is set to zero after insertion of SafeArea in the widget tree.
Since version 3.10.0, the window singleton is deprecated( https://docs.flutter.dev/release/breaking-changes/window-singleton). Therefore, to obtain the safe area padding, you must now apply the following:
``` MediaQueryData.fromView(ui.PlatformDispatcher.instance.implicitView!).padding ```