李卓原

update example,code annotation

... ... @@ -127,17 +127,17 @@ class _HomePageState extends State<HomePage> {
}
void printScreenInformation() {
print('Device width dp:${1.sw}'); //Device width
print('Device height dp:${1.sh}'); //Device height
print('Device pixel density:${ScreenUtil().pixelRatio}'); //Device pixel density
print('Device width dp:${1.sw}dp');
print('Device height dp:${1.sh}dp');
print('Device pixel density:${ScreenUtil().pixelRatio}');
print(
'Bottom safe zone distance dp:${ScreenUtil().bottomBarHeight}'); //Bottom safe zone distance,suitable for buttons with full screen
'Bottom safe zone distance dp:${ScreenUtil().bottomBarHeight}dp');
print(
'Status bar height px:${ScreenUtil().statusBarHeight}dp'); //Status bar height , Notch will be higher Unit px
'Status bar height dp:${ScreenUtil().statusBarHeight}dp');
print('Ratio of actual width dp to UI Design:${ScreenUtil().scaleWidth}');
print('Ratio of actual height dp to UI Design:${ScreenUtil().scaleHeight}');
print('System font scaling:${ScreenUtil().textScaleFactor}');
print('0.5 times the screen width:${0.5.sw}');
print('0.5 times the screen height:${0.5.sh}');
print('0.5 times the screen width:${0.5.sw}dp');
print('0.5 times the screen height:${0.5.sh}dp');
}
}
... ...
... ... @@ -116,8 +116,8 @@ class _HomePageState extends State<HomePage> {
}
void printScreenInformation() {
print('设备宽度:${1.sw}');
print('设备高度:${1.sh}');
print('设备宽度:${1.sw}dp');
print('设备高度:${1.sh}dp');
print('设备的像素密度:${ScreenUtil().pixelRatio}');
print('底部安全区距离:${ScreenUtil().bottomBarHeight}dp');
print('状态栏高度:${ScreenUtil().statusBarHeight}dp');
... ... @@ -126,7 +126,7 @@ class _HomePageState extends State<HomePage> {
print('宽度和字体相对于设计稿放大的比例:${ScreenUtil().scaleWidth * ScreenUtil().pixelRatio}');
print('高度相对于设计稿放大的比例:${ScreenUtil().scaleHeight * ScreenUtil().pixelRatio}');
print('系统的字体缩放比例:${ScreenUtil().textScaleFactor}');
print('屏幕宽度的0.5:${0.5.sw}');
print('屏幕高度的0.5:${0.5.sh}');
print('屏幕宽度的0.5:${0.5.sw}dp');
print('屏幕高度的0.5:${0.5.sh}dp');
}
}
... ...
... ... @@ -79,11 +79,11 @@ class ScreenUtil {
double get screenHeightPx => _screenHeight * _pixelRatio;
/// 状态栏高度 dp 刘海屏会更高
/// The offset from the top
/// The offset from the top, in dp
double get statusBarHeight => _statusBarHeight / _pixelRatio;
/// 底部安全区距离 dp
/// The offset from the bottom.
/// The offset from the bottom, in dp
double get bottomBarHeight => _bottomBarHeight / _pixelRatio;
/// 实际的dp与UI设计px的比例
... ...