Showing
3 changed files
with
13 additions
and
13 deletions
| @@ -127,17 +127,17 @@ class _HomePageState extends State<HomePage> { | @@ -127,17 +127,17 @@ class _HomePageState extends State<HomePage> { | ||
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | void printScreenInformation() { | 129 | void printScreenInformation() { |
| 130 | - print('Device width dp:${1.sw}'); //Device width | ||
| 131 | - print('Device height dp:${1.sh}'); //Device height | ||
| 132 | - print('Device pixel density:${ScreenUtil().pixelRatio}'); //Device pixel density | 130 | + print('Device width dp:${1.sw}dp'); |
| 131 | + print('Device height dp:${1.sh}dp'); | ||
| 132 | + print('Device pixel density:${ScreenUtil().pixelRatio}'); | ||
| 133 | print( | 133 | print( |
| 134 | - 'Bottom safe zone distance dp:${ScreenUtil().bottomBarHeight}'); //Bottom safe zone distance,suitable for buttons with full screen | 134 | + 'Bottom safe zone distance dp:${ScreenUtil().bottomBarHeight}dp'); |
| 135 | print( | 135 | print( |
| 136 | - 'Status bar height px:${ScreenUtil().statusBarHeight}dp'); //Status bar height , Notch will be higher Unit px | 136 | + 'Status bar height dp:${ScreenUtil().statusBarHeight}dp'); |
| 137 | print('Ratio of actual width dp to UI Design:${ScreenUtil().scaleWidth}'); | 137 | print('Ratio of actual width dp to UI Design:${ScreenUtil().scaleWidth}'); |
| 138 | print('Ratio of actual height dp to UI Design:${ScreenUtil().scaleHeight}'); | 138 | print('Ratio of actual height dp to UI Design:${ScreenUtil().scaleHeight}'); |
| 139 | print('System font scaling:${ScreenUtil().textScaleFactor}'); | 139 | print('System font scaling:${ScreenUtil().textScaleFactor}'); |
| 140 | - print('0.5 times the screen width:${0.5.sw}'); | ||
| 141 | - print('0.5 times the screen height:${0.5.sh}'); | 140 | + print('0.5 times the screen width:${0.5.sw}dp'); |
| 141 | + print('0.5 times the screen height:${0.5.sh}dp'); | ||
| 142 | } | 142 | } |
| 143 | } | 143 | } |
| @@ -116,8 +116,8 @@ class _HomePageState extends State<HomePage> { | @@ -116,8 +116,8 @@ class _HomePageState extends State<HomePage> { | ||
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | void printScreenInformation() { | 118 | void printScreenInformation() { |
| 119 | - print('设备宽度:${1.sw}'); | ||
| 120 | - print('设备高度:${1.sh}'); | 119 | + print('设备宽度:${1.sw}dp'); |
| 120 | + print('设备高度:${1.sh}dp'); | ||
| 121 | print('设备的像素密度:${ScreenUtil().pixelRatio}'); | 121 | print('设备的像素密度:${ScreenUtil().pixelRatio}'); |
| 122 | print('底部安全区距离:${ScreenUtil().bottomBarHeight}dp'); | 122 | print('底部安全区距离:${ScreenUtil().bottomBarHeight}dp'); |
| 123 | print('状态栏高度:${ScreenUtil().statusBarHeight}dp'); | 123 | print('状态栏高度:${ScreenUtil().statusBarHeight}dp'); |
| @@ -126,7 +126,7 @@ class _HomePageState extends State<HomePage> { | @@ -126,7 +126,7 @@ class _HomePageState extends State<HomePage> { | ||
| 126 | print('宽度和字体相对于设计稿放大的比例:${ScreenUtil().scaleWidth * ScreenUtil().pixelRatio}'); | 126 | print('宽度和字体相对于设计稿放大的比例:${ScreenUtil().scaleWidth * ScreenUtil().pixelRatio}'); |
| 127 | print('高度相对于设计稿放大的比例:${ScreenUtil().scaleHeight * ScreenUtil().pixelRatio}'); | 127 | print('高度相对于设计稿放大的比例:${ScreenUtil().scaleHeight * ScreenUtil().pixelRatio}'); |
| 128 | print('系统的字体缩放比例:${ScreenUtil().textScaleFactor}'); | 128 | print('系统的字体缩放比例:${ScreenUtil().textScaleFactor}'); |
| 129 | - print('屏幕宽度的0.5:${0.5.sw}'); | ||
| 130 | - print('屏幕高度的0.5:${0.5.sh}'); | 129 | + print('屏幕宽度的0.5:${0.5.sw}dp'); |
| 130 | + print('屏幕高度的0.5:${0.5.sh}dp'); | ||
| 131 | } | 131 | } |
| 132 | } | 132 | } |
| @@ -79,11 +79,11 @@ class ScreenUtil { | @@ -79,11 +79,11 @@ class ScreenUtil { | ||
| 79 | double get screenHeightPx => _screenHeight * _pixelRatio; | 79 | double get screenHeightPx => _screenHeight * _pixelRatio; |
| 80 | 80 | ||
| 81 | /// 状态栏高度 dp 刘海屏会更高 | 81 | /// 状态栏高度 dp 刘海屏会更高 |
| 82 | - /// The offset from the top | 82 | + /// The offset from the top, in dp |
| 83 | double get statusBarHeight => _statusBarHeight / _pixelRatio; | 83 | double get statusBarHeight => _statusBarHeight / _pixelRatio; |
| 84 | 84 | ||
| 85 | /// 底部安全区距离 dp | 85 | /// 底部安全区距离 dp |
| 86 | - /// The offset from the bottom. | 86 | + /// The offset from the bottom, in dp |
| 87 | double get bottomBarHeight => _bottomBarHeight / _pixelRatio; | 87 | double get bottomBarHeight => _bottomBarHeight / _pixelRatio; |
| 88 | 88 | ||
| 89 | /// 实际的dp与UI设计px的比例 | 89 | /// 实际的dp与UI设计px的比例 |
-
Please register or login to post a comment