How do I get the status bar height?
First, you need to assign a GlobalKey to the widget. If you've assigned the GlobalKey to the widget, you can get the currentContext property of the key and call the findRenderObject() method. The result can be casted to RenderBox . You can get the size from the RenderBox 's size property.
Step 1: Locate the MaterialApp widget. Step 2: Inside the MaterialApp, add the theme parameter with ThemeData class assigned. Step 3: Inside the ThemeData add the appBarTheme parameter and then assign the AppBarTheme class. Step 4: Inside the AppBarTheme , specify the systemOverlayStyle parameter and set the color.
var height = MediaQuery.of(context).viewPadding.top;
Note: This will only work on mobile devices because other platforms don't have a dedicated status bar and it will returns 0.0
for them.
Hope it will help you, just add latest GetX package in your application and import following library in your code.
import 'package:get/get.dart';
Status Bar Height
To get status bar height use following a bit code:
Get.statusBarHeight;
Bottom Bar Height
To get bottom bar height use following a bit code:
Get.bottomBarHeight;
Screen Height
To get screen height use following a bit code:
Get.height;
Screen Width
To get screen width use following a bit code:
Get.width;
Also you can use SafeArea()
widget to ignore overlays to use this just wrap your widget with this.
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