Skip to content

Commit bb98d5d

Browse files
author
李卓原
committed
update example,code annotation
1 parent 0c8b90a commit bb98d5d

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

example/lib/main.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,17 @@ class _HomePageState extends State<HomePage> {
127127
}
128128

129129
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}');
133133
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');
135135
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');
137137
print('Ratio of actual width dp to UI Design:${ScreenUtil().scaleWidth}');
138138
print('Ratio of actual height dp to UI Design:${ScreenUtil().scaleHeight}');
139139
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');
142142
}
143143
}

example/lib/main_zh.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ class _HomePageState extends State<HomePage> {
116116
}
117117

118118
void printScreenInformation() {
119-
print('设备宽度:${1.sw}');
120-
print('设备高度:${1.sh}');
119+
print('设备宽度:${1.sw}dp');
120+
print('设备高度:${1.sh}dp');
121121
print('设备的像素密度:${ScreenUtil().pixelRatio}');
122122
print('底部安全区距离:${ScreenUtil().bottomBarHeight}dp');
123123
print('状态栏高度:${ScreenUtil().statusBarHeight}dp');
@@ -126,7 +126,7 @@ class _HomePageState extends State<HomePage> {
126126
print('宽度和字体相对于设计稿放大的比例:${ScreenUtil().scaleWidth * ScreenUtil().pixelRatio}');
127127
print('高度相对于设计稿放大的比例:${ScreenUtil().scaleHeight * ScreenUtil().pixelRatio}');
128128
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');
131131
}
132132
}

lib/screenutil.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ class ScreenUtil {
7979
double get screenHeightPx => _screenHeight * _pixelRatio;
8080

8181
/// 状态栏高度 dp 刘海屏会更高
82-
/// The offset from the top
82+
/// The offset from the top, in dp
8383
double get statusBarHeight => _statusBarHeight / _pixelRatio;
8484

8585
/// 底部安全区距离 dp
86-
/// The offset from the bottom.
86+
/// The offset from the bottom, in dp
8787
double get bottomBarHeight => _bottomBarHeight / _pixelRatio;
8888

8989
/// 实际的dp与UI设计px的比例

0 commit comments

Comments
 (0)