Problem accounting for different status bar + notch sizes across different phones
Hi! First of all, thank you for such an amazing library! It works perfectly when I am not dealing with any appbars or status bars (when I am designing for full screen). However, when I finally need to take into account status bar + app bar, the library behaves unpredictably.
For example, for a design blueprint (iPhone X on Figma) screen size of (375, 812), I have a Column of components as follows:
- Status bar + notch --> 44.h from original blueprint (but variable for each phone)
- Appbar (preferred size) --> 44.h
- Box --> 96.h
- Another box --> 628.h
- Total = 44 + 44 + 96 + 628 = 812
Now for my Pixel 3 emulator, setting status bar + notch to 14.h does the trick. However for other phones this does not work. I am not quite sure how to account for the differing status bar + notch heights. I am also not sure how to make use of ScreenUtil().statusBarHeight, as I have tried somehow including it in the equation but can't seem to make it work. Can you please assist me on this? Do let me know if you need more info. Thanks! (Apologies for my lack of understanding on how to use your library if ever)

Now, the initialization of the latest version has been changed to the unit of dp, but because of the greater impact, you can still use px, but I am not sure whether the version has processed the pixel density. The following content is based on the latest version: In addition, the method of obtaining the height of the status bar, the unit of the value obtained is pd, and the unit of obtaining the height of the screen is also dp. If you are not sure about the behavior of the currently used version, you can view the comments of the corresponding method. In addition, there are official methods to obtain the height of the status bar and the height of the screen:
MediaQuery.of(context).padding.top
MediaQuery.of(context).size.height
Thank you for the swift reply. I've actually discovered a formula for calculating the proper height of the app bar given different status bar sizes.
a' = app bar height in code (in dp) a = app bar height in blueprint (in dp) s' = status bar height in code (in dp), retrievable by ScreenUtil().statusBarHeight s = status bar height in bueprint (in dp)
Magic formula is --> a' + s' = (a + s).h So I used a' = (a + s).h - s' to get the proper app bar height that changes based on status bar of any phone and maintains the total number of pixels in the height. In code, this is how it looks:
appBar: PreferredSize(
preferredSize: Size(375.w, (88.h - ScreenUtil().statusBarHeight))
// 88.h is the combined height of app bar and status bar in the iPhone X blueprint (44.h + 44.h)
Just sharing this in case it might be helpful to everyone. Also not sure whether you @lizhuoyuan intended this magic formula but it's there and it works like a charm. Again, thank you for your great work on the library!