flutter screen width and height of the status bar height

MediaQuery.of (context) contains some of the attributes of the screen:

size: Object comprising a width and height, the unit is dp

print(MediaQuery.of(context).size);     //输出: Size(411.4, 683.4) 

devicePixelRatio: Returns the pixel density devices

print(MediaQuery.of(context).devicePixelRatio);  //2.625

textScaleFactor: font number of pixels per logical pixel. The default is 1.0

Get the value of the top and bottom margins. (Mainly for bangs screen)

final double topPadding = MediaQuery.of(context).padding.top;
final double bottomPadding = MediaQuery.of(context).padding.bottom;

Note that:
the top margin on iPhoneX value is 44, the value of the other devices 20, the height of the cell containing the strip.
Margin value is in iPhoneX 34, the value 0 is on other devices.

dart: window objects in ui
before use to import the package in the file header: import 'dart: ui';

Then we look at the common properties and methods of the Window:

defaultRouteName → String 启动应用程序时嵌入器请求的路由或路径。
devicePixelRatio → double 每个逻辑像素的设备像素数。 例如,Nexus 6的设备像素比为3.5。
textScaleFactor → double 系统设置的文本比例。默认1.0
toString() → String 返回此对象的字符串表示形式。
physicalSize → Size 返回一个包含屏幕宽高的对象,单位是dp

Guess you like

Origin www.cnblogs.com/qqcc1388/p/11463276.html